def main(args):
    gfhash = gff3.get_gff_hash(args['gffile'])
    gid, Diagstart, Diagstop = get_coordinates_for_diagram(
        gfhash, args['genes'])
    print gid, Diagstart, Diagstop

    gd_diagram = GenomeDiagram.Diagram(gid)
    gd_track_for_features = gd_diagram.new_track(1, name="Annotated Genes")
    gd_feature_set = gd_track_for_features.new_set()

    for gf in sorted(gfhash[gid], key=lambda x: x.start):
        if gf.ftype != 'mRNA': continue
        if gf.start > gf.stop: gf.start, gf.stop = gf.stop, gf.start
        if gf.stop < Diagstart or gf.start > Diagstop: continue
        f = SeqFeature(FeatureLocation(max([gf.start, Diagstart]),
                                       min([gf.stop, Diagstop])),
                       strand=int(gf.strand + '1'),
                       type=gf.get_attributes()['ID'])
        gd_feature_set.add_feature(f,
                                   label=True,
                                   label_size=10,
                                   label_angle=0,
                                   sigil="ARROW")
        print gf.get_attributes()['ID'], gf.start, gf.stop

    gd_diagram.draw(start=Diagstart,
                    end=Diagstop,
                    format='linear',
                    fragments=1,
                    pagesize=(100 * cm, 4 * cm))
    outfile = os.path.split(args['gffile'])[1] + "_" + string.join(
        args['genes'], "_") + '.pdf'
    gd_diagram.write(outfile, "PDF")
    print outfile
def main( args ):
  gfhash = gff3.get_gff_hash(args['gffile'])
  sys.stderr.write("gff loaded ")
  gid, startpos, endpos = get_coordinates(gfhash, args['genes'])
  sys.stderr.write("| coordinates identified ")
  if not args['rv']: print ">%s_%s:%s" %(gid, startpos, endpos)
  else: print ">%s_%s:%s" %(gid, endpos, startpos)
  
  seqhash = fasta.get_sequence_hash(args['fastafile'])
  sys.stderr.write("| fasta loaded ")
  seq = seqhash[gid][startpos-1:endpos]
  if args['rv']: seq = Seq(seq).reverse_complement().tostring()
  sys.stderr.write("| subsequence extracted ")
  print seq
  sys.stderr.write("\n")
Esempio n. 3
0
def main(args):
    gfhash = gff3.get_gff_hash(args['gffile'])
    sys.stderr.write("gff loaded ")
    gid, startpos, endpos = get_coordinates(gfhash, args['genes'])
    sys.stderr.write("| coordinates identified ")
    if not args['rv']: print ">%s_%s:%s" % (gid, startpos, endpos)
    else: print ">%s_%s:%s" % (gid, endpos, startpos)

    seqhash = fasta.get_sequence_hash(args['fastafile'])
    sys.stderr.write("| fasta loaded ")
    seq = seqhash[gid][startpos - 1:endpos]
    if args['rv']: seq = Seq(seq).reverse_complement().tostring()
    sys.stderr.write("| subsequence extracted ")
    print seq
    sys.stderr.write("\n")
def main( args ):
  gfhash = gff3.get_gff_hash(args['gffile'])
  gid, Diagstart, Diagstop = get_coordinates_for_diagram(gfhash, args['genes'])
  print gid, Diagstart, Diagstop
  
  gd_diagram = GenomeDiagram.Diagram(gid)
  gd_track_for_features = gd_diagram.new_track(1, name="Annotated Genes")
  gd_feature_set = gd_track_for_features.new_set()
  
  for gf in sorted(gfhash[gid], key=lambda x: x.start):
    if gf.ftype != 'mRNA': continue
    if gf.start > gf.stop: gf.start, gf.stop = gf.stop, gf.start
    if gf.stop < Diagstart or gf.start > Diagstop: continue
    f = SeqFeature(FeatureLocation(max([gf.start, Diagstart]), min([gf.stop, Diagstop])), strand=int(gf.strand+'1'), type=gf.get_attributes()['ID'])
    gd_feature_set.add_feature(f, label=True, label_size=10, label_angle=0, sigil="ARROW")
    print gf.get_attributes()['ID'], gf.start, gf.stop
  
  gd_diagram.draw(start=Diagstart, end=Diagstop, format='linear', fragments=1, pagesize=(100*cm, 4*cm))
  outfile = os.path.split(args['gffile'])[1] + "_"+ string.join(args['genes'], "_") + '.pdf'
  gd_diagram.write(outfile, "PDF")
  print outfile