-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from standage/feature/mrna
New mRNA module, generator cognate for AEGeAn's pmrna command
- Loading branch information
Showing
12 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
mains = { | ||
'gff3': tag.cli.gff3.main, | ||
'occ': tag.cli.occ.main, | ||
'pmrna': tag.cli.pmrna.main, | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (C) 2015 Daniel Standage <daniel.standage@gmail.com> | ||
# | ||
# This file is part of tag (http://github.com/standage/tag) and is licensed | ||
# under the BSD 3-clause license: see LICENSE. | ||
# ----------------------------------------------------------------------------- | ||
|
||
from __future__ import print_function | ||
import argparse | ||
from collections import defaultdict | ||
from intervaltree import IntervalTree | ||
import tag | ||
|
||
|
||
def subparser(subparsers): | ||
subparser = subparsers.add_parser('pmrna') | ||
subparser.add_argument('-r', '--relax', action='store_false', default=True, | ||
dest='strict', help='relax parsing stringency') | ||
subparser.add_argument('gff3', help='input file') | ||
|
||
|
||
def main(args): | ||
reader = tag.GFF3Reader(infilename=args.gff3, strict=args.strict) | ||
writer = tag.GFF3Writer(tag.mrna.primary(reader)) | ||
writer.write() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (C) 2016 Daniel Standage <daniel.standage@gmail.com> | ||
# | ||
# This file is part of tag (http://github.com/standage/tag) and is licensed | ||
# under the BSD 3-clause license: see LICENSE. | ||
# ----------------------------------------------------------------------------- | ||
|
||
import tag | ||
|
||
|
||
def primary(entrystream, parenttype='gene'): | ||
for entry in entrystream: | ||
if not isinstance(entry, tag.feature.Feature): | ||
yield entry | ||
continue | ||
|
||
for feature in tag.select.features(entry, parenttype, traverse=True): | ||
mrnas = [m for m in tag.select.features(feature.children, 'mRNA')] | ||
mrnas.sort(key=lambda m: (m.cdslen, m.get_attribute('ID'))) | ||
mrnas.pop() | ||
feature.children = [c for c in feature.children if c not in mrnas] | ||
yield entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (C) 2016 Daniel Standage <daniel.standage@gmail.com> | ||
# | ||
# This file is part of tag (http://github.com/standage/tag) and is licensed | ||
# under the BSD 3-clause license: see LICENSE. | ||
# ----------------------------------------------------------------------------- | ||
|
||
import pytest | ||
import tag | ||
|
||
|
||
def test_primary(): | ||
reader = tag.reader.GFF3Reader(tag.pkgdata('nanosplice.gff3')) | ||
gene = next(tag.select.features(tag.mrna.primary(reader), type='gene')) | ||
assert gene.cdslen is None | ||
assert gene.num_children == 1 | ||
assert gene.children[0].get_attribute('ID') == 'mRNAsecond' | ||
|
||
reader = tag.reader.GFF3Reader(tag.pkgdata('pdom-withseq.gff3')) | ||
for gene in tag.select.features(tag.mrna.primary(reader), type='gene'): | ||
assert gene.num_children == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
##gff-version 3 | ||
##sequence-region 42 5001 12000 | ||
42 nano gene 5001 12000 . - . ID=gene1 | ||
42 nano mRNA 5001 12000 . - . ID=mRNA1;Parent=gene1 | ||
42 nano CDS 5001 6000 . - 1 Parent=mRNA1 | ||
42 nano CDS 9001 10000 . - 2 Parent=mRNA1 | ||
42 nano CDS 11001 12000 . - 0 Parent=mRNA1 | ||
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
42 nano gene 5001 12000 . - . ID=gene1 | ||
42 nano mRNA 5001 12000 . - . ID=mRNAfirst;Parent=gene1 | ||
42 nano CDS 5001 6000 . - 1 ID=CDS1;Parent=mRNAfirst | ||
42 nano CDS 7001 8000 . - 2 ID=CDS1;Parent=mRNAfirst | ||
42 nano CDS 11001 12000 . - 0 ID=CDS1;Parent=mRNAfirst | ||
42 nano mRNA 5001 12000 . - . ID=mRNAsecond;Parent=gene1 | ||
42 nano CDS 5001 6000 . - 1 ID=CDS2;Parent=mRNAsecond | ||
42 nano CDS 9001 10000 . - 2 ID=CDS2;Parent=mRNAsecond | ||
42 nano CDS 11001 12000 . - 0 ID=CDS2;Parent=mRNAsecond |