Skip to content

Commit

Permalink
Invert logic of "fixing" primer scheme bed files
Browse files Browse the repository at this point in the history
While the ivar tool wrappers know how to fix ARTIC-style broken primer
scheme bed files on the fly, the ARTIC minion pipeline actually depends
on the score column being *not* a number.
  • Loading branch information
wm75 committed Oct 12, 2020
1 parent 63af670 commit b93b0d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
DATA_TABLE_NAME = "primer_scheme_bedfiles"


def write_good_bed(input_file, bed_output_filename):
def write_artic_style_bed(input_file, bed_output_filename):
with open(bed_output_filename, "w") as bed_output_file:
for line in input_file:
fields = line.split("\t")
Expand All @@ -27,10 +27,16 @@ def write_good_bed(input_file, bed_output_filename):
exit("invalid format in BED file: {}".format(line.rstrip()))
try:
# try and parse field 5 as a number
float(fields[4])
score = float(fields[4])
except ValueError:
# ARTIC with broken BED, set field 5 to 60
fields[4] = "60"
# Alright, this is an ARTIC-style bed,
# which is actually against the specs, but required by the
# ARTIC pipeline.
pass
else:
# This is a regular bed with numbers in the score column.
# We need to "fix" it for the ARTIC pipeline.
fields[4] = '_{0}'.format(score)
bed_output_file.write("\t".join(fields))


Expand All @@ -56,7 +62,7 @@ def fetch_artic_primers(output_directory, primers):
)
exit(response.status_code)
bed_output_filename = os.path.join(output_directory, name + ".bed")
write_good_bed(StringIO(response.text), bed_output_filename)
write_artic_style_bed(StringIO(response.text), bed_output_filename)
description = name[:-2] + " " + name[-2:] + " primer set"
data.append(dict(value=name, path=bed_output_filename, description=description))
return data
Expand All @@ -68,7 +74,7 @@ def install_primer_file(
name = re.sub(r"\W", "", str(primer_name).replace(" ", "_"))
output_filename = os.path.join(output_directory, name + ".bed")
with open(input_filename) as input_file:
write_good_bed(input_file, output_filename)
write_artic_style_bed(input_file, output_filename)
data = [dict(value=name, description=primer_description, path=output_filename)]
return data

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="data_manager_primer_scheme_bedfiles" name="BED-format primer scheme data manager" version="0.0.11" tool_type="manage_data" profile="19.05">
<tool id="data_manager_primer_scheme_bedfiles" name="BED-format primer scheme data manager" version="0.0.12" tool_type="manage_data" profile="19.05">
<requirements>
<requirement type="package" version="2.24.0">requests</requirement>
</requirements>
Expand Down Expand Up @@ -61,7 +61,7 @@
</test>
</tests>
<help><![CDATA[
Amplicon sequencing for viral pathogens using the `PrimalSeq and iVar`_ relies on
Amplicon sequencing for viral pathogens using the ARTIC_ pipeline or `PrimalSeq and iVar`_ relies on
identifying primer locations in a reference sequence using BED format files. This
data manager populates a Galaxy tool data table, either from files provided via
a history or via the ARTIC_ network Github repository.
Expand Down

0 comments on commit b93b0d4

Please sign in to comment.