-
Notifications
You must be signed in to change notification settings - Fork 6
Allows for CDS (as well as gene) features to generate a new gene reference #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,18 +3,27 @@ | |
| from Bio.SeqFeature import SeqFeature, FeatureLocation, Seq | ||
| import shutil | ||
| import argparse | ||
| import sys | ||
|
|
||
| def new_reference(referencefile, outgenbank, outfasta, gene): | ||
| ref = SeqIO.read(referencefile, "genbank") | ||
| startofgene = None | ||
| endofgene = None | ||
| for feature in ref.features: | ||
| if feature.type == 'source': | ||
| ref_source_feature = feature | ||
| if feature.type =='gene': | ||
| if feature.type =='gene' or feature.type == 'CDS': | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we'd use a centralised GenBank parser, such as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh, I'm open to using For extending to "gene feature types" is this basically adding a duplicate code block like the following? if feat.type=='gene':
# ... copy internal code from "if feat.type=='CDS'"I assume if both a "gene" and a "CDS" feature are named "E", one won't overwrite the nucleotide coordinates of the other (although hopefully they match)?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for nextstrain/augur#1435! Upon review, and in order to not hold up progress here (and measles), I'd suggest using the code as it stands and then we can move to using a util function once we're happy with the changes there. |
||
| a = list(feature.qualifiers.items())[0][-1][0] | ||
| if a == gene: | ||
| startofgene = int(list(feature.location)[0]) | ||
| endofgene = int(list(feature.location)[-1])+1 | ||
|
|
||
| # 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 is not None and startofgene is None and endofgene is 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) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.