[Bio] / FigTutorial / features_around.py Repository:
ViewVC logotype

Annotation of /FigTutorial/features_around.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : disz 1.1 from FigKernelPackages import FIG
2 :     import sys
3 :     import string
4 :    
5 :     fig = FIG.FIG()
6 :    
7 :     def die(msg):
8 :     print msg
9 :     sys.exit(0)
10 :    
11 :     if len(sys.argv) != 2:
12 :     die("usage: features_around ID")
13 :    
14 :     id = sys.argv[1]
15 :    
16 :     peg = fig.by_alias(id)
17 :     if peg:
18 :     loc = fig.feature_location(peg)
19 :     if loc:
20 :     try:
21 :     (contig,beg,end) = fig.boundaries_of(loc)
22 :     start_reg = int(fig.min(beg,end)) - 5000
23 :     end_reg = int(fig.max(beg,end)) + 5000
24 :     genome = fig.genome_of(peg)
25 :     (features_in_region,start_of_leftmost_feature,end_of_rightmost_feature) = fig.genes_in_region(genome,contig,start_reg,end_reg);
26 :     for fid in features_in_region:
27 :     loc1 = fig.feature_location(fid)
28 :     aliases1 = fig.feature_aliases(fid)
29 :     trunc = fig.possibly_truncated(fid)
30 :    
31 :     pseq = func = prot_ln = ""
32 :    
33 :     if fig.ftype(fid) == "peg":
34 :     prot_ln = fig.translation_length(fid)
35 :     if prot_ln:
36 :     pseq = fig.get_translation(fid)
37 :     func = fig.function_of(fid)
38 :     print string.join([fid, loc1, str(aliases1), str(trunc), str(func), str(prot_ln), pseq], "\t")
39 :     #print join("\t",($fid,$loc1,$aliases1,$trunc,$func,$prot_ln,$pseq)),"\n";
40 :     except:
41 :     pass
42 :     else:
43 :     sys.stderr.write("Sorry, could not get the location of %s\n" % fid)
44 :     #print STDERR "Sorry, could not get the location of $fid\n";
45 :     else:
46 :     sys.stderr.write("Sorry, could not figure out which PEG you meant by %s\n" % id)
47 :     #print STDERR "Sorry, could not figure out which PEG you meant by $id\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3