diff --git a/scripts/newreference.py b/scripts/newreference.py index 015688f..4e6c3d4 100644 --- a/scripts/newreference.py +++ b/scripts/newreference.py @@ -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")