Ejemplo n.º 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)
Ejemplo n.º 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'
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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'
Ejemplo n.º 6
0
                                               name=domain_obj.short_name,
                                               fc=12)
            else:
                dfeat = features.DomainFeature([feat],
                                               name=domain_obj.short_name,
                                               fc=colors_4_this_domain)
            dfeat = features.DomainFeature([feat], name=domain_obj.short_name)
            test_track.append(dfeat)

    if is_domain_on_same_line:
        #dfeat = features.DomainFeature(feats, name=domain_names, seq_line=(1,seq_length), fc=colors[0:len(feats)])
        colors_4_this_domain = map(lambda x: domain_colors[x], domain_names)
        print domain_names
        dfeat = features.DomainFeature(
            feats,
            name=domain_names,
            seq_line=(1, seq_length),
            #ec = 'None', fc=colors_4_this_domain, color_by_cm = False)
            ec='None',
            color_by_cm=False)
        test_track.append(dfeat)

    panel.add_track(test_track)
    #panel.tracks = [test_track]

    if not output:
        output = os.path.join(outdir, seq_title + '.png')
    #if counter==6:  print output
    print output
    panel.save(output)
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)

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

dfeat = features.DomainFeature([feat,feat2],name = ['test domain 1', 'test domain 2'], height = 1.5, boxstyle = ['sawtooth, tooth_size=1.4',  'rarrow, pad = 0.1'],  seq_line = (1, 766), ec = 'None')
test_track.append(dfeat)


dfeat = features.DomainFeature([feat,feat2],name = ['', 'test domain 2'],height = 1.5, boxstyle = ['round4, rounding_size=1.4',  'larrow, pad = 0.1'],   ec = 'None', fc = ['y', 'c'], color_by_cm = False)
test_track.append(dfeat)

panel.add_track(test_track)
panel.save('domain_test.png')