Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/schema_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"assembly": {
"type": "string",
"pattern": "^\\S+\\.(fa|fna|fasta)$",
"pattern": "^.+\\.(fa|fasta|fna)(\\.gz)?$",
"errorMessage": "The assembly needs to be a fasta file"
},
"user_gff": {
Expand Down Expand Up @@ -44,7 +44,7 @@
"maxLength": 0
}
]
},
}
},
"required": ["sample", "assembly"]
}
Expand Down
30 changes: 17 additions & 13 deletions bin/assembly_filter_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from Bio import SeqIO
import argparse
import fileinput
import os


def rename(input_file, prefix):
Expand All @@ -27,19 +29,21 @@ def rename(input_file, prefix):
with open(output_1kb, "w") as to_1kb, open(output_5kb, "w") as to_5kb, open(
output_map, "w"
) as to_map, open(output_100kb, "w") as to_100kb:
for counter, record in enumerate(SeqIO.parse(input_file, "fasta"), 1):
new_id = ">contig_" + str(counter)
my_chain = str(record.seq).upper()
to_map.write(new_id + "\t" + str(record.id) + "\n")
if len(my_chain) > 1000:
to_1kb.write(new_id + "\n")
to_1kb.write(my_chain + "\n")
if len(my_chain) > 5000:
to_5kb.write(new_id + "\n")
to_5kb.write(my_chain + "\n")
if len(my_chain) >= 100000:
to_100kb.write(new_id + "\n")
to_100kb.write(my_chain + "\n")
real_path = os.path.realpath(input_file)
with fileinput.hook_compressed(real_path, "rt") as file_in:
for counter, record in enumerate(SeqIO.parse(file_in, "fasta"), 1):
new_id = ">contig_" + str(counter)
my_chain = str(record.seq).upper()
to_map.write(new_id + "\t" + str(record.id) + "\n")
if len(my_chain) > 1000:
to_1kb.write(new_id + "\n")
to_1kb.write(my_chain + "\n")
if len(my_chain) > 5000:
to_5kb.write(new_id + "\n")
to_5kb.write(my_chain + "\n")
if len(my_chain) >= 100000:
to_100kb.write(new_id + "\n")
to_100kb.write(my_chain + "\n")


def main():
Expand Down
3 changes: 2 additions & 1 deletion workflows/mobilomeannotation.nf
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ workflow MAIN {
}
}

assembly_files = ch_inputs.map { meta, fasta, _user_proteins_gff, _virify_gff -> [meta, fasta] }
// PREPROCESSING
RENAME( ch_inputs.map { meta, fasta, _user_proteins_gff, _virify_gff -> [meta, fasta] } )
RENAME( assembly_files )

// PROKKA annotation is optional and is skipped by default.
// When PROKKA annotation is activated, AMRfinder plus run as well
Expand Down