Skip to content

Commit

Permalink
adjust the grep -w condition
Browse files Browse the repository at this point in the history
  • Loading branch information
chien-chi committed Dec 5, 2024
1 parent 0b76f8f commit cb6b97d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions amplicov/amplicov
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ def convert_bed_to_amplicon_dict(input,cov_array,RefID="",unique=False, count_pr
cov_zero_array = np.zeros_like(cov_array)
amplicon=defaultdict(dict)
primers_pos=list()
RefID = '""' if RefID is None else RefID
cmd = 'grep -v alt %s | grep -w %s | paste - - | cut -f 2,3,4,8,9 | sed -e "s/_LEFT//g" -e "s/_RIGHT//g" ' % (input_bed, RefID)
if RefID:
cmd = 'grep -v alt %s | grep -w %s | paste - - | cut -f 2,3,4,8,9 | sed -e "s/_LEFT//g" -e "s/_RIGHT//g" ' % (input_bed, RefID)
else:
cmd = 'grep -v alt %s | paste - - | cut -f 2,3,4,8,9 | sed -e "s/_LEFT//g" -e "s/_RIGHT//g" ' % (input_bed)

proc = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
previous_id=''
outs, errs = proc.communicate()
Expand Down Expand Up @@ -120,8 +123,10 @@ def convert_bedpe_to_amplicon_dict(input,cov_array,RefID="",unique=False, count_
cov_zero_array = np.zeros_like(cov_array)
amplicon=defaultdict(dict)
primers_pos=list()
RefID = '""' if RefID is None else RefID
cmd = 'grep -w %s %s | cut -f 2,3,5,6,7 ' % (RefID, input_bedpe)
if RefID:
cmd = 'grep -w %s %s | cut -f 2,3,5,6,7 ' % (RefID, input_bedpe)
else:
cmd = 'cut -f 2,3,5,6,7 %s ' % (input_bedpe)
proc = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
previous_id=''
outs, errs = proc.communicate()
Expand Down

0 comments on commit cb6b97d

Please sign in to comment.