Skip to content

Commit

Permalink
Merge branch 'dev' into fix/virsorter2
Browse files Browse the repository at this point in the history
  • Loading branch information
KateSakharova authored Nov 8, 2024
2 parents 380ad87 + 0c20229 commit aa7a9ab
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions bin/write_viral_gff.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ def aggregate_annotations(virify_annotation_files):
return viral_sequences, cds_annotations


def open_fasta_file(filename):
if filename.endswith('.gz'):
f = gzip.open(filename, "rt")
else:
f = open(filename, "rt")
return f


def write_gff(
checkv_files,
taxonomy_files,
Expand Down Expand Up @@ -183,11 +191,13 @@ def empty_if_number(string):
taxonomy_dict[contig] = taxonomy_string

# Read unmodified contig length from the renamed assembly file
for record in SeqIO.parse(assembly_file, "fasta"):
handle = open_fasta_file(assembly_file)
for record in SeqIO.parse(handle, "fasta"):
contig_id = str(record.id)
seq_len = len(str(record.seq))
contigs_len_dict[contig_id] = seq_len

handle.close()

with open(output_filename, "w") as gff:
print("##gff-version 3", file=gff)
# Constants
Expand Down

0 comments on commit aa7a9ab

Please sign in to comment.