>>> import tag
>>>
>>> gene = tag.Feature("chrom", "gene", 0, 100)
>>> cds1 = tag.Feature("chrom", "CDS", 0, 60)
>>> cds2 = tag.Feature("chrom", "CDS", 0, 90)
>>> pep1 = tag.Feature("chrom", "mat_pep", 1, 58)
>>> pep1 = tag.Feature("chrom", "mat_pep", 1, 28)
>>> pep2 = tag.Feature("chrom", "mat_pep", 31, 58)
>>> pep3 = tag.Feature("chrom", "mat_pep", 61, 88)
>>>
>>> gene.add_child(cds1)
>>> gene.add_child(cds2)
>>>
>>> cds1.add_child(pep1)
>>> cds2.add_child(pep1)
>>>
>>> cds1.add_child(pep2)
>>> cds2.add_child(pep2)
>>>
>>> cds2.add_child(pep3)
>>>
>>> print(repr(gene))
chrom tag gene 1 100 . . . .
chrom tag CDS 1 60 . . . .
chrom tag CDS 1 90 . . . .
chrom tag mat_pep 2 28 . . . .
chrom tag mat_pep 32 58 . . . .
chrom tag mat_pep 62 88 . . . .
>>>
>>> w = tag.GFF3Writer([gene])
>>> w.write()
##gff-version 3
chrom tag gene 1 100 . . . ID=gene1
chrom tag CDS 1 60 . . . ID=CDS1;Parent=gene1
chrom tag CDS 1 90 . . . ID=CDS2;Parent=gene1
chrom tag mat_pep 2 28 . . . Parent=CDS2
chrom tag mat_pep 32 58 . . . Parent=CDS2
chrom tag mat_pep 62 88 . . . Parent=CDS2
###
>>>
>>> import tag
>>>
>>> gene = tag.Feature("chrom", "gene", 0, 100, attrstr="ID=g1")
>>> cds1 = tag.Feature("chrom", "CDS", 0, 60, attrstr="ID=c1")
>>> cds2 = tag.Feature("chrom", "CDS", 0, 90, attrstr="ID=c2")
>>> pep1 = tag.Feature("chrom", "mat_pep", 1, 58)
>>> pep1 = tag.Feature("chrom", "mat_pep", 1, 28)
>>> pep2 = tag.Feature("chrom", "mat_pep", 31, 58)
>>> pep3 = tag.Feature("chrom", "mat_pep", 61, 88)
>>>
>>> gene.add_child(cds1)
>>> cds1.add_attribute("Parent", "g1")
>>> gene.add_child(cds2)
>>> cds2.add_attribute("Parent", "g1")
>>>
>>> cds1.add_child(pep1)
>>> cds2.add_child(pep1)
>>> pep1.add_attribute("Parent", "c1", append=True)
>>> pep1.add_attribute("Parent", "c2", append=True)
>>>
>>> cds1.add_child(pep2)
>>> cds2.add_child(pep2)
>>> pep2.add_attribute("Parent", "c1", append=True)
>>> pep2.add_attribute("Parent", "c2", append=True)
>>>
>>> cds2.add_child(pep3)
>>> pep3.add_attribute("Parent", "c2")
>>>
>>> print(repr(gene))
chrom tag gene 1 100 . . . ID=g1
chrom tag CDS 1 60 . . . ID=c1;Parent=g1
chrom tag CDS 1 90 . . . ID=c2;Parent=g1
chrom tag mat_pep 2 28 . . . Parent=c1,c2
chrom tag mat_pep 32 58 . . . Parent=c1,c2
chrom tag mat_pep 62 88 . . . Parent=c2
>>>
>>> w = tag.GFF3Writer([gene])
>>> w.write()
##gff-version 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/daniel.standage/Software/tag/tag/writer.py", line 87, in write
feature.add_attribute('ID', fid)
File "/Users/daniel.standage/Software/tag/tag/feature.py", line 444, in add_attribute
oldvalue=oldid)
File "/Users/daniel.standage/Software/tag/tag/feature.py", line 455, in add_attribute
assert oldvalue in self._attrs[attrkey]
AssertionError
>>>