Skip to content

Commit

Permalink
fixup: move gene check before trying to extract the sequence feature
Browse files Browse the repository at this point in the history
  • Loading branch information
j23414 committed Mar 8, 2024
1 parent 3400636 commit 61af263
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/newreference.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ def new_reference(referencefile, outgenbank, outfasta, gene):
startofgene = int(list(feature.location)[0])
endofgene = int(list(feature.location)[-1])+1

record = ref[startofgene:endofgene]
source_feature = SeqFeature(FeatureLocation(start=0, end=len(record)), type='source',
qualifiers=ref_source_feature.qualifiers)
record.features.append(source_feature)

# If user provides a --gene 'some name' is not found, print a warning and use the entire genome.
# Otherwise do not print a warning.
if(gene != None and startofgene==None and endofgene==None):
print(f"ERROR: No '{gene}' was found under 'gene' or 'CDS' features in the GenBank file.", file=sys.stderr)
sys.exit(1)

record = ref[startofgene:endofgene]
source_feature = SeqFeature(FeatureLocation(start=0, end=len(record)), type='source',
qualifiers=ref_source_feature.qualifiers)
record.features.append(source_feature)

SeqIO.write(record, outgenbank, 'genbank')
SeqIO.write(record, outfasta, "fasta")

Expand Down

0 comments on commit 61af263

Please sign in to comment.