Beispiel #1
0
def doWork( args ):
    panel=Panel(fig_width=900, padding = 25, grid=None, xmin=0)
    seq_length = 0
    for gff in args.gffs:
        seqrecord = GFF.parse(gff).next()
        if len(seqrecord) > seq_length:
            seq_length = len(seqrecord)
        #seqrecord = SeqIO.parse(args.infile, "genbank").next()
        cds_track = tracks.BaseTrack(sort_by = 'collapse')
        for feature in seqrecord.features:
            if feature.type == 'CDS':
                #print feature.qualifiers['product']
                if feature.qualifiers['product'][0] == 'hypothetical protein':
                    col = '#BDBDBD'
                else:
                    col = '#2B8CBE'
                feat = features.GenericSeqFeature(feature, color_by_cm=False,
                        fc=col )
                cds_track.append(feat)
            elif feature.type == 'source':
                cds_track.append(features.GenericSeqFeature(feature,
                    color_by_cm=False, alpha=0.0, fc='1.0', ec='1.0'))
            else:
                cds_track.append(features.GenericSeqFeature(feature,
                    color_by_cm=False, fc='0.0', ec='0.0'))
        panel.add_track(cds_track)
    panel.save(args.outfile, xmin=0,xmax=seq_length)
Beispiel #2
0
def drawFeatures2(tks, highlight=[], filename=None, color=None, **kwargs):
    from biograpy import Panel, tracks, features
    panel = Panel(fig_width=500,
                  fig_height=150,
                  fig_dpi=100,
                  padding=10,
                  grid='both')
    for feats in tks:
        test_track = tracks.BaseTrack(name='X', height=.2)
        for feat in feats:
            if feat.location.strand == -1:
                arr = "larrow,pad=0.6"
            else:
                arr = "rarrow,pad=0.6"
            q = feat.qualifiers
            tag = q['locus_tag'][0]
            test_track.append(
                features.GenericSeqFeature(
                    feat,
                    name=tag,
                    boxstyle=arr,
                ))
        panel.add_track(test_track)
    if filename == None:
        filename = 'genediagram'
    panel.save(filename + '.png')
    panel.close()
    return filename + '.png'
Beispiel #3
0
def doWork(args):
    panel = Panel(fig_width=900, padding=25, grid=None, xmin=0)
    seq_length = 0
    for gff in args.gffs:
        seqrecord = GFF.parse(gff).next()
        if len(seqrecord) > seq_length:
            seq_length = len(seqrecord)
        #seqrecord = SeqIO.parse(args.infile, "genbank").next()
        cds_track = tracks.BaseTrack(sort_by='collapse')
        for feature in seqrecord.features:
            if feature.type == 'CDS':
                #print feature.qualifiers['product']
                if feature.qualifiers['product'][0] == 'hypothetical protein':
                    col = '#BDBDBD'
                else:
                    col = '#2B8CBE'
                feat = features.GenericSeqFeature(feature,
                                                  color_by_cm=False,
                                                  fc=col)
                cds_track.append(feat)
            elif feature.type == 'source':
                cds_track.append(
                    features.GenericSeqFeature(feature,
                                               color_by_cm=False,
                                               alpha=0.0,
                                               fc='1.0',
                                               ec='1.0'))
            else:
                cds_track.append(
                    features.GenericSeqFeature(feature,
                                               color_by_cm=False,
                                               fc='0.0',
                                               ec='0.0'))
        panel.add_track(cds_track)
    panel.save(args.outfile, xmin=0, xmax=seq_length)
Beispiel #4
0
 def test_simple_features(self):
     panel=Panel(fig_width=1000)#initialize a drawer
     test_track = tracks.BaseTrack(features.Simple(name='feat1',start=100,end=756,),
         features.Simple(name='feat2',start=300,end=1056,),
         features.Simple(name='feat3',start=600,end=1356,),
         features.Simple(name='feat4',start=800,end=1356,),
         features.Simple(name='feat5',start= 1357,end=1806,),
         name = 'test')
     panel.add_track(test_track)
     fh = tempfile.TemporaryFile()
     panel.save(fh, format='png')
     fh.seek(0)
     img = Image.open(fh)
     #self.assertEqual(img.size, (1000, 220))
     self.assertEqual(img.format, 'PNG')
Beispiel #5
0
def drawFeatures2(tks, highlight=[], filename=None, color=None, **kwargs):
    from biograpy import Panel, tracks, features
    panel=Panel(fig_width=500,fig_height=150, fig_dpi=100,padding=10,
                grid='both')
    for feats in tks:
        test_track = tracks.BaseTrack(name = 'X',
                                       height = .2)
        for feat in feats:
            if feat.location.strand == -1:
                arr = "larrow,pad=0.6"
            else:
                arr = "rarrow,pad=0.6"
            q=feat.qualifiers
            tag=q['locus_tag'][0]
            test_track.append(features.GenericSeqFeature(feat,
                              name=tag,boxstyle=arr,
                              ))
        panel.add_track(test_track)
    if filename==None:
        filename = 'genediagram'
    panel.save(filename+'.png')
    panel.close()
    return filename+'.png'
            raise "seq_length cannot be obtained"
    else:
        raise "length has to be given by either --length, --seq_length or --seq"

    if is_gene_name_replace_protein_name:
        m = re.search('([^.]+)', seq_title)
        seq_title = m.group(1)
    else:
        pass
    print seq_title

    for domain_obj in domain_objs:
        print domain_obj.start

    # draw domain structure using BioGraPy
    panel = Panel(fig_dpi=100)

    #if not test_track:
    test_track = tracks.BaseTrack(name=seq_title, sort_by=None)

    for index, domain_obj in enumerate(domain_objs):
        dfeat = None
        feat = SeqFeature.SeqFeature()
        start, stop = domain_obj.start, domain_obj.stop
        #feat.location = SeqFeature.FeatureLocation(start, stop)
        feat.location = SeqFeature.FeatureLocation(1, 100)
        feats.append(feat)
        domain_names.append(domain_obj.short_name)
        if is_domain_on_same_line:
            continue
        if is_domain_on_diff_line:
from biograpy import Panel, tracks, features
from Bio import SeqFeature

panel = Panel(fig_width=900)

test_track = tracks.BaseTrack(name = 'domains', sort_by = None, cm = 'Set3')

feat = SeqFeature.SeqFeature()
feat.location = SeqFeature.FeatureLocation(100, 300)

dfeat = features.DomainFeature([feat], name = 'test domain 1', seq_line = (1, 766))
test_track.append(dfeat)

dfeat = features.DomainFeature([feat],name = 'test domain 1', height = 1.5, seq_line = (1, 766))
test_track.append(dfeat)

dfeat = features.DomainFeature([feat],name = 'test domain 1', height = 1.5, boxstyle = 'round4, rounding_size=1.4',  seq_line = (1, 766))
test_track.append(dfeat)

dfeat = features.DomainFeature([feat],name = 'test domain 1',height = 1.5, boxstyle = 'larrow, pad = 0',  seq_line = (1, 766))
test_track.append(dfeat)

dfeat = features.DomainFeature([feat], name = 'test domain 1',height = 1.5, boxstyle = 'round ',  seq_line = (1, 766))
test_track.append(dfeat)

feat2 = SeqFeature.SeqFeature()
feat2.location = SeqFeature.FeatureLocation(500, 700)

dfeat = features.DomainFeature([feat,feat2], name = 'test domain 1',height = 1.5, boxstyle = 'roundtooth, pad = 0.1, tooth_size=1.2',  seq_line = (1, 766), alpha = 0.7)
test_track.append(dfeat)
Beispiel #8
0



from biograpy import Panel, tracks, features
panel=Panel(fig_width=1000, )#initialize a drawer
test_track = tracks.BaseTrack(features.Simple(name='feat1',start=100,end=756,),
            features.Simple(name='feat2',start=300,end=1056,),
            features.Simple(name='feat3',start=600,end=1356,),
            features.Simple(name='feat4',start=800,end=1356,),
            features.Simple(name='feat5',start= 1357,end=1806,),
            name = 'test')
panel.append(test_track)

panel.save('test.png')
Beispiel #9
0
from biograpy import Panel, tracks, features
panel = Panel(fig_width=1000, )  #initialize a drawer
test_track = tracks.BaseTrack(features.Simple(
    name='feat1',
    start=100,
    end=756,
),
                              features.Simple(
                                  name='feat2',
                                  start=300,
                                  end=1056,
                              ),
                              features.Simple(
                                  name='feat3',
                                  start=600,
                                  end=1356,
                              ),
                              features.Simple(
                                  name='feat4',
                                  start=800,
                                  end=1356,
                              ),
                              features.Simple(
                                  name='feat5',
                                  start=1357,
                                  end=1806,
                              ),
                              name='test')
panel.append(test_track)

panel.save('test.png')
    seq_length = seq_length
elif seq_file:
    seq_objs = get_length_from_seq_file(seq_file,'fasta')
    if seq_title in seq_objs:
        seq_length = seq_objs[seq_title].length
    else:
        raise "seq_length cannot be obtained"
else:
    raise "length has to be given by either --length, --seq_length or --seq"

for domain_obj in domain_objs:
    print domain_obj.start


# draw domain structure using BioGraPy
panel = Panel(fig_dpi=100)
test_track = tracks.BaseTrack(name = seq_title, sort_by = None)


for index,domain_obj in enumerate(domain_objs):
    feat = SeqFeature.SeqFeature()
    start, stop = domain_obj.start, domain_obj.stop
    feat.location = SeqFeature.FeatureLocation(start, stop)
    feats.append(feat)
    domain_names.append(domain_obj.short_name)
    if is_domain_on_same_line:
        continue
    if index == 0:
        dfeat = features.DomainFeature([feat], name=domain_obj.short_name, seq_line=(1,seq_length))
    else:
        dfeat = features.DomainFeature([feat], name=domain_obj.short_name)
Beispiel #11
0
#!usr/bin/python