[Bio] / FigTutorial / API.html Repository:
ViewVC logotype

Diff of /FigTutorial/API.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Tue May 25 18:30:40 2004 UTC revision 1.2, Wed Jun 16 14:09:09 2004 UTC
# Line 242  Line 242 
242          <a href=URL>LABEL</a>          <a href=URL>LABEL</a>
243  </pre>  </pre>
244  </ul>  </ul>
245  We suggest that you type in this program and gget it to run on your  
246    We suggest that you type in this program and get it to run on your
247  version of the SEED.  Then, use <b>fig</b> to delete any links you  version of the SEED.  Then, use <b>fig</b> to delete any links you
248  added.  added.
249    
250  <h2>Accessing Data Relating to Genomes</h2>  <h2>Accessing Data Relating to Genomes</h2>
251    
252  Let us now begin a somewhat more systematic exploration of the services offered by the API.  Let us now begin a somewhat more systematic exploration of the services offered by the API.
253  We will begin with genome-related services, of which there are relatively few in the SEED.  We will begin with genome-related services, of which there are relatively few in the SEED.
254  Essentially, genomes are represented by IDs of the form <i>xxx.y</i>  Essentially, genomes are represented by IDs of the form <i>xxx.y</i>
255  where <i>xxx</i> is the NCBI taxon ID, and <i>y</i> is a suffix to  where <i>xxx</i> is the NCBI taxon ID, and <i>y</i> is a suffix to
256  disambiguate situations in which you have multiple genomes with the  disambiguate situations in which you have multiple genomes with the
257  same taxon ID.  same taxon ID.
258    <p>
259    <blockquote>
260    <table border="1">
261    <tr>
262    <td>genomes.ex.pl</td>
263    <td>genomes.ex.py</td>
264    </tr>
265    <tr>
266    <td bgcolor="f0f0f0"><pre>
267    
 <hr>  
 <pre>  
268  use strict;  use strict;
269  use FIG;  use FIG;
270  my $fig = new FIG;  my $fig = new FIG;
# Line 284  Line 294 
294      $sofar->{$nonunique}++;      $sofar->{$nonunique}++;
295      return $nonunique . ".$n";      return $nonunique . ".$n";
296  }  }
297  </pre>  </pre></td>
298    <td bgcolor="f0f0f0"><pre>
299    from FigKernelPackages import FIG
300    import sys
301    import string
302    
303    
304    def die(msg):
305            print msg
306            sys.exit(0)
307    
308    fig = FIG.FIG()
309    sofar = {}
310    
311    def get_unique_abbreviation(which, sofar):
312        nonunique = fig.abbrev(which);
313        nonunique = string.rstrip(string.replace(nonunique," ",  ""), ".")
314        if not sofar.has_key(nonunique):
315            sofar[nonunique] = 1
316        n = sofar[nonunique]
317        sofar[nonunique] = sofar[nonunique] + 1
318        return (nonunique+"."+str(n))
319    
320    for genome in fig.genomes("complete"):
321        which   = fig.genus_species(genome)
322        abbrev  = get_unique_abbreviation(which,sofar);
323        version = fig.genome_version(genome);
324        print "%s\t%s\t%s\t%s" % (genome, abbrev, version, which)
325    
326    </pre></td>
327    </tr>
328    </table>
329    </blockquote>
330    
331  <h3>An illustration of genome-related services</h3>  <h3>An illustration of genome-related services</h3>
332    
333  <hr>  <hr>
334  There are a few points worth noting about the short example:  There are a few points worth noting about the short example:
335  <ul>  <ul>
336  <li>  <li>
337    
338  <i>$fig->genomes</i> returns a list of all of the genome IDs.  It has  <i>$fig->genomes</i> returns a list of all of the genome IDs.  It has
339  two arguments that can be omitted.  The first is used to request only  two arguments that can be omitted.  The first is used to request only
340  complete (or near complete) genomes (this is used in the example).  complete (or near complete) genomes (this is used in the example).
# Line 344  Line 389 
389  the contigs for a designated genome.  For each contig that is over 50  the contigs for a designated genome.  For each contig that is over 50
390  characters in size (and, they all should be), it displays the contig  characters in size (and, they all should be), it displays the contig
391  ID, the contig length, and the first 50 characters of sequence.  ID, the contig length, and the first 50 characters of sequence.
392    <p>
393    <blockquote>
394    <table border="1">
395    <tr>
396    <td>contigs_for_genome.pl</td>
397    <td>contigs_for_genome.py</td>
398    </tr>
399    <tr>
400    <td bgcolor="f0f0f0"><pre>
401    
 <hr>  
 <pre>  
402  use strict;  use strict;
403  use FIG;  use FIG;
404  my $fig = new FIG;  my $fig = new FIG;
# Line 369  Line 421 
421      }      }
422  }  }
423    
424  </pre>  </pre></td>
425    <td bgcolor="f0f0f0"><pre>
426    from FigKernelPackages import FIG
427    import sys
428    
429    fig = FIG.FIG()
430    
431    def die(msg):
432            print msg
433            sys.exit(0)
434    
435    if len(sys.argv) != 2:
436            die("usage: contigs_for_genome Genome")
437    
438    genome = sys.argv[1]
439    
440    contigs =  fig.all_contigs(genome)
441    
442    for contig in contigs:
443        len = fig.contig_ln(genome,contig)
444        if len >= 50:
445            seq = fig.dna_seq(genome,contig+"_1_50")
446            print contig+"\t"+len+"\t"+seq
447    
448    </pre></td>
449    </tr>
450    </table>
451    </blockquote>
452    
453  <h3>How to access services related to contigs</h3>  <h3>How to access services related to contigs</h3>
454  <hr>  <hr>
455  The services being used in this short example are as follows:  The services being used in this short example are as follows:
# Line 439  Line 519 
519  from the web services offered by the SEED.  As an introduction to some  from the web services offered by the SEED.  As an introduction to some
520  of these capabilities, consider the following short program:  of these capabilities, consider the following short program:
521    
522  <hr>  <p>
523  <pre>  <blockquote>
524    <table border="1">
525    <tr>
526    <td>features_around.pl</td>
527    <td>features_around.py</td>
528    </tr>
529    <tr>
530    <td bgcolor="f0f0f0"><pre>
531    
532  use strict;  use strict;
533  my($usage,$id,$fid,$peg,$loc,$contig,$beg,$end,$start_reg,$end_reg);  my($usage,$id,$fid,$peg,$loc,$contig,$beg,$end,$start_reg,$end_reg);
534  my($loc1,$aliases1,$trunc,$pseq,$prot_ln,$func,$features_in_region);  my($loc1,$aliases1,$trunc,$pseq,$prot_ln,$func,$features_in_region);
# Line 496  Line 584 
584  {  {
585      print STDERR "Sorry, could not figure out which PEG you meant by $id\n";      print STDERR "Sorry, could not figure out which PEG you meant by $id\n";
586  }  }
587  </pre>  </pre></td>
588    <td bgcolor="f0f0f0"><pre>
589    from FigKernelPackages import FIG
590    import sys
591    import string
592    
593    fig = FIG.FIG()
594    
595    def die(msg):
596            print msg
597            sys.exit(0)
598    
599    if len(sys.argv) != 2:
600            die("usage: features_around ID")
601    
602    id = sys.argv[1]
603    
604    peg = fig.by_alias(id)
605    if peg:
606        loc = fig.feature_location(peg)
607        if loc:
608            try:
609                (contig,beg,end) = fig.boundaries_of(loc)
610                start_reg = int(fig.min(beg,end)) - 5000
611                end_reg   = int(fig.max(beg,end)) + 5000
612                genome = fig.genome_of(peg)
613                (features_in_region,start_of_leftmost_feature,end_of_rightmost_feature) = fig.genes_in_region(genome,contig,start_reg,end_reg);
614                for fid in features_in_region:
615                    loc1     = fig.feature_location(fid)
616                    aliases1 = fig.feature_aliases(fid)
617                    trunc    = fig.possibly_truncated(fid)
618    
619                    pseq = func = prot_ln = ""
620    
621                    if fig.ftype(fid) == "peg":
622                        prot_ln = fig.translation_length(fid)
623                        if prot_ln:
624                            pseq = fig.get_translation(fid)
625                            func = fig.function_of(fid)
626                    print string.join([fid, loc1, str(aliases1), str(trunc), str(func), str(prot_ln), pseq], "\t")
627                    #print join("\t",($fid,$loc1,$aliases1,$trunc,$func,$prot_ln,$pseq)),"\n";
628            except:
629                    pass
630        else:
631            sys.stderr.write("Sorry, could not get the location of %s\n" % fid)
632            #print STDERR "Sorry, could not get the location of $fid\n";
633    else:
634        sys.stderr.write("Sorry, could not figure out which PEG you meant by %s\n" % id)
635        #print STDERR "Sorry, could not figure out which PEG you meant by $id\n";
636    </pre></td>
637    </tr>
638    </table>
639    </blockquote>
640  <h3>Displaying features close to a given feature</h3>  <h3>Displaying features close to a given feature</h3>
641  <hr>  <hr>
642  This short program takes as an argument an ID that corresponds to a  This short program takes as an argument an ID that corresponds to a
# Line 678  Line 818 
818  how to handle nonstandard translations or properly translating the  how to handle nonstandard translations or properly translating the
819  first codon:  first codon:
820    
821  <hr>  <p>
822  <pre>  <blockquote>
823    <table border="1">
824    <tr>
825    <td>seq_utils.pl</td>
826    <td>seq_utils.py</td>
827    </tr>
828    <tr>
829    <td bgcolor="f0f0f0"><pre>
830    
831  use FIG;  use FIG;
832  my $fig = new FIG;  my $fig = new FIG;
833    
834    # seq_utils 31312.1 NC_000927_9431_9048 > stdout 2> stderr
835    
836  $usage = "usage: seq_utils Genome Location";  $usage = "usage: seq_utils Genome Location";
837    
838  (  (
# Line 705  Line 855 
855      &FIG::display_id_and_seq("minus_strand_translated",\$tranR,\*STDERR);      &FIG::display_id_and_seq("minus_strand_translated",\$tranR,\*STDERR);
856  }  }
857    
858  </pre>  </pre></td>
859    <td bgcolor="f0f0f0"><pre>
860    from FigKernelPackages import FIG
861    import sys
862    
863    fig = FIG.FIG()
864    
865    def die(msg):
866            print msg
867            sys.exit(0)
868    
869    if len(sys.argv) != 3:
870            die("usage: seq_utils Genome Location")
871    
872    genome = sys.argv[1]
873    loc = sys.argv[2]
874    
875    seq = fig.dna_seq(genome, loc)
876    
877    if seq:
878        seqR = fig.reverse_comp(seq);
879    
880        tran  = fig.translate(seq);
881        tranR = fig.translate(seqR);
882    
883        fig.display_id_and_seq("plus_strand",seq);
884        #fig.display_id_and_seq("plus_strand_translated",\$tran,\*STDERR);
885    
886        fig.display_id_and_seq("minus_strand",seqR);
887        #fig.display_id_and_seq("minus_strand_translated",\$tranR,\*STDERR);
888    </pre></td>
889    </tr>
890    </table>
891    </blockquote>
892    
893  <h3>Using some simple sequence utilities</h3>  <h3>Using some simple sequence utilities</h3>
894  <hr>  <hr>
895  The program takes two command-line arguments: a  The program takes two command-line arguments: a
# Line 887  Line 1071 
1071  <li> the function assigned to the similar sequence.  <li> the function assigned to the similar sequence.
1072  </ul>  </ul>
1073    
1074  <hr>  <p>
1075  <pre>  <blockquote>
1076    <table border="1">
1077    <tr>
1078    <td>show_similarities.pl</td>
1079    <td>show_similarities.py</td>
1080    </tr>
1081    <tr>
1082    <td bgcolor="f0f0f0"><pre>
1083  use FIG;  use FIG;
1084  my $fig = new FIG;  my $fig = new FIG;
1085  use Sim;  use Sim;
# Line 923  Line 1114 
1114      $func2  = $fig->function_of($id2);      $func2  = $fig->function_of($id2);
1115      print join("\t",($ln1,$id2,$ln2,$pscore,$iden,$b1,$e1,$b2,$e2,$func2)),"\n";      print join("\t",($ln1,$id2,$ln2,$pscore,$iden,$b1,$e1,$b2,$e2,$func2)),"\n";
1116  }  }
1117  </pre>  </pre></td>
1118    <td bgcolor="f0f0f0"><pre>
1119    from FigKernelPackages import FIG
1120    import sys, string
1121    
1122    fig = FIG.FIG()
1123    id1_ix = 0
1124    ln1_ix = 12
1125    id2_ix = 1
1126    ln2_ix = 13
1127    iden_ix = 2
1128    psc_ix = 10
1129    ali_ln_ix = 3
1130    mismatches_ix = 4
1131    gaps_ix = 5
1132    bsc_ix = 11
1133    b1_ix = 6
1134    e1_ix = 7
1135    b2_ix = 8
1136    e2_ix = 9
1137    bit_score_ix = 11
1138    tool_ix = 14
1139    def2_ix = 15
1140    ali_ix = 16
1141    
1142    
1143    def die(msg):
1144            print msg
1145            sys.exit(0)
1146    
1147    if len(sys.argv) != 5:
1148            die("usage: show_similarities PEG CutOFF MaxReturned Expand")
1149    
1150    
1151    peg = sys.argv[1]
1152    cutoff = sys.argv[2]
1153    max = sys.argv[3]
1154    expand = sys.argv[4]
1155    
1156    sims = fig.sims(peg, max, cutoff, "all", expand)
1157    
1158    for sim in sims:
1159        ln1    = str(sim[ln1_ix])
1160        id2    = str(sim[id2_ix])
1161        ln2    = str(sim[ln2_ix])
1162        pscore = str(sim[psc_ix])
1163        iden   = str(sim[iden_ix])
1164        b1     = str(sim[b1_ix])
1165        e1     = str(sim[e1_ix])
1166        b2     = str(sim[b2_ix])
1167        e2     = str(sim[e2_ix])
1168        func2  = fig.function_of(id2)
1169        print string.join((ln1, id2, ln2, pscore, iden, b1, e1, b2, e2, func2[1]), "\t")
1170    </pre></td>
1171    </tr>
1172    </table>
1173    </blockquote>
1174    
1175  <h3>How to Access Similarities</h3>  <h3>How to Access Similarities</h3>
1176  <hr>  <hr>
# Line 1049  Line 1296 
1296  preserved contiguity:  preserved contiguity:
1297  The following short program illustrates its use:  The following short program illustrates its use:
1298    
1299  <hr>  <p>
1300  <pre>  <blockquote>
1301    <table border="1">
1302    <tr>
1303    <td>show_functional_coupling.pl</td>
1304    <td>show_functional_coupling.py</td>
1305    </tr>
1306    <tr>
1307    <td bgcolor="f0f0f0"><pre>
1308  use FIG;  use FIG;
1309  my $fig = new FIG;  my $fig = new FIG;
1310  use strict;  use strict;
1311    
1312  my($usage,$bound,$sim_cutoff,$fc_cutoff,@fc,$tuple,$peg);  my($usage,$bound,$sim_cutoff,$fc_cutoff,@fc,$tuple,$peg);
1313    
1314  $usage = "usage: fc Bound SimCutoff FcCutOff < PEGs > PEG1-Sc-PEGs";  $usage = "usage: show_functional_coupling Bound SimCutoff FcCutOff < PEGs > PEG1-Sc-PEGs";
1315    
1316  (  (
1317   ($bound = shift @ARGV) &&   ($bound = shift @ARGV) &&
# Line 1074  Line 1328 
1328          @fc = $fig->coupling_and_evidence($peg,$bound,$sim_cutoff,$fc_cutoff);          @fc = $fig->coupling_and_evidence($peg,$bound,$sim_cutoff,$fc_cutoff);
1329          foreach $tuple (@fc)          foreach $tuple (@fc)
1330          {          {
1331              print &Dumper($tuple);  #           print &Dumper($tuple);
1332                print "$peg\t$tuple->[0]\t$tuple->[1]\n";
1333          }          }
1334      }      }
1335  }  }
1336  </pre>  </pre></td>
1337    <td bgcolor="f0f0f0"><pre>
1338    from FigKernelPackages import FIG2
1339    import sys, re
1340    
1341    fig = FIG2.FIG()
1342    
1343    def die(msg):
1344            print msg
1345            sys.exit(0)
1346    
1347    if len(sys.argv) != 4:
1348            die("usage: fc Bound SimCutoff FcCutOff < PEGs > PEG1-Sc-PEGs")
1349    
1350    
1351    bound = sys.argv[1]
1352    sim_cutoff = sys.argv[2]
1353    fc_cutoff = sys.argv[3]
1354    
1355    for line in sys.stdin.readlines():
1356        match =  re.search("^(fig\|\d+\.\d+\.peg\.\d+)", line)
1357        if match:
1358            peg = match.group(1)
1359            fc  = fig.coupling_and_evidence(peg, bound, sim_cutoff, fc_cutoff)
1360            for tuple in fc:
1361                print "%s\t%s\t%s" % ( peg, tuple[0], tuple[1])
1362    </pre></td>
1363    </tr>
1364    </table>
1365    </blockquote>
1366    
1367  <h3>How to compute functional coupling scores based on preserved contiguity</h3>  <h3>How to compute functional coupling scores based on preserved contiguity</h3>
1368  <hr>  <hr>
# Line 1442  Line 1726 
1726  </pre>  </pre>
1727    
1728  Now let's examine the short program that produced the output:  Now let's examine the short program that produced the output:
1729  <hr>  
1730  <pre>  <p>
1731    <blockquote>
1732    <table border="1">
1733    <tr>
1734    <td>connect_map_to_genes.pl</td>
1735    <td>connect_map_to_genes.py</td>
1736    </tr>
1737    <tr>
1738    <td bgcolor="f0f0f0"><pre>
1739  use FIG;  use FIG;
1740  my $fig = new FIG;  my $fig = new FIG;
1741  use Sim;  use Sim;
# Line 1461  Line 1753 
1753    
1754  $name = $fig->map_name($map);  $name = $fig->map_name($map);
1755  print "$map\t$name\n";  print "$map\t$name\n";
1756  foreach $role ($fig->map_to_roles($map))  foreach $role ($fig->map_to_ecs($map))
1757  {  {
1758      print "  $role\n";      print "  $role\n";
1759      foreach $peg ($fig->seqs_with_role($role,"master",$genome))      foreach $peg ($fig->seqs_with_role($role,"master",$genome))
# Line 1470  Line 1762 
1762          print "    $peg\t$func\n";          print "    $peg\t$func\n";
1763      }      }
1764  }  }
1765  </pre>  </pre></td>
1766    <td bgcolor="f0f0f0"><pre>
1767    from FigKernelPackages import FIG2
1768    import sys
1769    
1770    fig = FIG2.FIG()
1771    
1772    def die(msg):
1773            print msg
1774            sys.exit(0)
1775    
1776    if len(sys.argv) != 3:
1777            die("usage: connect_map_to_genes Map Genome")
1778    
1779    map = sys.argv[1]
1780    genome = sys.argv[2]
1781    name = fig.map_name(map);
1782    
1783    print "%s\t%s" % (map, name)
1784    roles = fig.map_to_ecs(map)
1785    for role in roles:
1786        print role
1787        pegs = fig.seqs_with_role(role,"master",genome)
1788        for peg in pegs:
1789            func = fig.function_of(peg);
1790            print "    %s\t%s" % (peg, func[0][1])
1791    </pre></td>
1792    </tr>
1793    </table>
1794    </blockquote>
1795    
 <h3>Locating genes within an organism that connect to a specific map</h3>  
 <hr>  
 There arev a number of details worth noting in this little program:  
 <ul>  
 <li> the invocation  
 <pre>  
         $fig->map_name($map)  
 </pre>  
1796  returns the full name associated with the map.  returns the full name associated with the map.
1797  <li>You can get the the list of functional roles contained within a map using  <li>You can get the the list of functional roles contained within a map using
1798  <pre>  <pre>
# Line 1508  Line 1821 
1821  the subsystem.  With this in mind, the following program should be  the subsystem.  With this in mind, the following program should be
1822  reasonably clear:  reasonably clear:
1823    
1824  <hr>  <p>
1825  <pre>  <blockquote>
1826    <table border="1">
1827    <tr>
1828    <td>connect_subsystem_to_genes.pl</td>
1829    <td>connect_subsystem_to_genes.py</td>
1830    </tr>
1831    <tr>
1832    <td bgcolor="f0f0f0"><pre>
1833    
1834  use FIG;  use FIG;
1835  my $fig = new FIG;  my $fig = new FIG;
1836  use Sim;  use Sim;
# Line 1535  Line 1856 
1856          print "    $peg\t$func\n";          print "    $peg\t$func\n";
1857      }      }
1858  }  }
1859  </pre>  </pre></td>
1860    <td bgcolor="f0f0f0"><pre>
1861    from FigKernelPackages import FIG2
1862    import sys
1863    
1864    fig = FIG2.FIG()
1865    
1866    def die(msg):
1867            print msg
1868            sys.exit(0)
1869    
1870    if len(sys.argv) != 3:
1871            die("usage: connect_subsystem_to_genes Subsystem Genome")
1872    
1873    subsystem  = sys.argv[1]
1874    genome = sys.argv[2]
1875    
1876    print subsystem
1877    roles = fig.subsystem_to_roles(subsystem)
1878    for role in roles:
1879        print role
1880        pegs = fig.seqs_with_role(role,"master",genome)
1881        for peg in pegs:
1882            func = fig.function_of(peg);
1883            print "%s\t%s" % ( peg, func[0][1])
1884    </pre></td>
1885    </tr>
1886    </table>
1887    </blockquote>
1888    
1889  <h3>Locating genes within an organism that connect to a specific subsystem</h3>  <h3>Locating genes within an organism that connect to a specific subsystem</h3>
1890  <hr>  <hr>
# Line 1564  Line 1913 
1913  of which genes implement specific roles.  This leads to my assertion  of which genes implement specific roles.  This leads to my assertion
1914  that the following program is a better way to display a subsystem:  that the following program is a better way to display a subsystem:
1915    
1916  <hr>  <p>
1917  <pre>  <blockquote>
1918    <table border="1">
1919    <tr>
1920    <td>connect_subsystem_to_genes_the_right_way.pl</td>
1921    <td>connect_subsystem_to_genes_the_right_way.py</td>
1922    </tr>
1923    <tr>
1924    <td bgcolor="f0f0f0"><pre>
1925    
1926  use FIG;  use FIG;
1927  my $fig = new FIG;  my $fig = new FIG;
1928  use Sim;  use Sim;
# Line 1585  Line 1942 
1942  foreach $role ($fig->subsystem_to_roles($subsystem))  foreach $role ($fig->subsystem_to_roles($subsystem))
1943  {  {
1944      print "  $role\n";      print "  $role\n";
1945      foreach $peg ($fig->pegs_in_subsystem_cell($genome,$role))      foreach $peg ($fig->pegs_in_subsystem_cell($subsystem, $genome, $role))
1946      {      {
1947          $func = $fig->function_of($peg);          $func = $fig->function_of($peg);
1948          print "    $peg\t$func\n";          print "    $peg\t$func\n";
1949      }      }
1950  }  }
1951  </pre>  </pre></td>
1952    <td bgcolor="f0f0f0"><pre>
1953    from FigKernelPackages import FIG2
1954    import sys
1955    
1956    fig = FIG2.FIG()
1957    
1958    def die(msg):
1959            print msg
1960            sys.exit(0)
1961    
1962    if len(sys.argv) != 3:
1963            die("usage: connect_subsystem_to_genes_the_right_way Subsystem Genome")
1964    
1965    subsystem = sys.argv[1]
1966    genome  = sys.argv[2]
1967    
1968    print subsystem
1969    roles = fig.subsystem_to_roles(subsystem)
1970    
1971    for role in roles:
1972        print role
1973        pegs = fig.pegs_in_subsystem_cell(subsystem, genome, role)
1974        for peg in pegs:
1975            func = fig.function_of(peg)
1976            print "    %s\t%s" % (peg, func[0][1])
1977    </pre></td>
1978    </tr>
1979    </table>
1980    </blockquote>
1981    
1982  <h3>Locating genes within an organism that connect to a specific  <h3>Locating genes within an organism that connect to a specific
1983  subsystem the right way</h3>  subsystem the right way</h3>
# Line 1605  Line 1991 
1991  The following program illustrates the services required to answer this  The following program illustrates the services required to answer this
1992  question;  question;
1993    
1994  <hr>  <p>
1995  <pre>  <blockquote>
1996    <table border="1">
1997    <tr>
1998    <td>gf2maps_and_subs.pl</td>
1999    <td>gf2maps_and_subs.py</td>
2000    </tr>
2001    <tr>
2002    <td bgcolor="f0f0f0"><pre>
2003  use FIG;  use FIG;
2004  my $fig = new FIG;  my $fig = new FIG;
2005    
# Line 1636  Line 2029 
2029          }          }
2030      }      }
2031    
2032      @maps_it_connects_to       = sort keys(%in_maps);      @maps_it_connects_to       = sort keys(%in_map);
2033    
2034      if (@maps_it_connects_to > 0)      if (@maps_it_connects_to > 0)
2035      {      {
# Line 1665  Line 2058 
2058          print "$subsystem\n";          print "$subsystem\n";
2059      }      }
2060  }  }
2061  </pre>  </pre></td>
2062    <td bgcolor="f0f0f0"><pre>
2063    from FigKernelPackages import FIG2
2064    import sys
2065    
2066    fig = FIG2.FIG()
2067    
2068    def die(msg):
2069            print msg
2070            sys.exit(0)
2071    
2072    if len(sys.argv) != 2:
2073            die("usage: gf2maps_and_subs PEG")
2074    
2075    # The single input argument must be a FIG id, which is used to get the assigned function.
2076    # The program then prints a list of maps to which the gene can be connected,
2077    # followed by a list of subsystems that contain the gene.
2078    
2079    peg = sys.argv[1]
2080    
2081    func = fig.function_of(peg)
2082    func = func[0][1]
2083    hypo = fig.hypo(func)
2084    in_map = {}
2085    
2086    if func and hypo[0] == 0:
2087        roles = fig.roles_of_function(func)
2088        for role in roles:
2089            maps = fig.role_to_maps(role)
2090            for map in maps:
2091                in_map[map] = 1
2092    
2093        maps_it_connects_to = in_map.keys()
2094        maps_it_connects_to.sort()
2095    
2096        if len(maps_it_connects_to) > 0:
2097            print "Maps that connect to %s\n" % func
2098            for map in maps_it_connects_to:
2099                map_name = fig.map_name(map)
2100                print "%s\t%s" % (map, map_name[0])
2101            print " ";
2102    else:
2103        sys.stderr.write("you need to give a valid PEG with a non-hypothetical function to connect to maps\n")
2104    
2105    subsystems_it_is_in = fig.peg_to_subsystems(peg)
2106    
2107    if len(subsystems_it_is_in) > 0:
2108        print "Subsystems that contain %s\n" % peg
2109        for subsystem in subsystems_it_is_in:
2110            print subsystem
2111    </pre></td>
2112    </tr>
2113    </table>
2114    </blockquote>
2115    
2116  <h3>Going from a PEG to the maps and subsystems containing it</h3>  <h3>Going from a PEG to the maps and subsystems containing it</h3>
2117  <hr>  <hr>
2118  Here, again, there are some of points worth discussing:  Here, again, there are some of points worth discussing:
# Line 1736  Line 2183 
2183  events in chronilogical order.  The following short example  events in chronilogical order.  The following short example
2184  illustrates this utility:  illustrates this utility:
2185    
2186  <hr>  <p>
2187  <pre>  <blockquote>
2188    <table border="1">
2189    <tr>
2190    <td>annotations_of.pl</td>
2191    <td>annotations_of.py</td>
2192    </tr>
2193    <tr>
2194    <td bgcolor="f0f0f0"><pre>
2195  use FIG;  use FIG;
2196  my $fig = new FIG;  my $fig = new FIG;
2197  use strict;  use strict;
# Line 1773  Line 2227 
2227          print "=======\n\n";          print "=======\n\n";
2228      }      }
2229  }  }
2230    </pre></td>
2231    <td bgcolor="f0f0f0"><pre>
2232    from FigKernelPackages import FIG
2233    import sys
2234    
2235    def display_annotations(annotations):
2236        for annotation in annotations:
2237            fid,timestamp,user,text = annotation
2238            print "=======\n";
2239            print "%s\t%s\t%s\n%s\n" % ( user, timestamp, fid, text)
2240            print "=======\n\n"
2241    
2242    fig = FIG.FIG()
2243    
2244    def die(msg):
2245            print msg
2246            sys.exit(0)
2247    
2248    if len(sys.argv) < 2:
2249            die("usage: annotations_of Fid1, Fid2, ... ")
2250    
2251    fig_ids = sys.argv[1:]
2252    
2253    annotations = fig.merged_related_annotations(fig_ids)
2254    if len(annotations) > 0:
2255        display_annotations(annotations)
2256    else:
2257        sys.stderr.write("Sorry, there were no annotations attached to the features\n")
2258    
2259    </pre></td>
2260    </tr>
2261    </table>
2262    </blockquote>
2263    
2264    
 </pre>  
2265  <h3>Accessing the annotations from a set of features</h3>  <h3>Accessing the annotations from a set of features</h3>
2266  <hr>  <hr>
2267  Invoking this little utility using  Invoking this little utility using
# Line 1808  Line 2295 
2295  annotations to record the events.  Here is a simple utility  annotations to record the events.  Here is a simple utility
2296  that can be used to make annotations:  that can be used to make annotations:
2297    
2298  <hr>  <p>
2299  <pre>  <blockquote>
2300    <table border="1">
2301    <tr>
2302    <td>batch_assignments.pl</td>
2303    </tr>
2304    <tr>
2305    <td bgcolor="f0f0f0"><pre>
2306  use FIG;  use FIG;
2307  my $fig = new FIG;  my $fig = new FIG;
2308    
# Line 1856  Line 2349 
2349      }      }
2350  }  }
2351    
2352    </pre></td>
2353    </tr>
2354    </table>
2355    </blockquote>
2356    
 </pre>  
2357  <h3>A utility to make batch assignments</h3>  <h3>A utility to make batch assignments</h3>
2358  <hr>  <hr>
2359  Before discussing the details of this code, we should discuss the  Before discussing the details of this code, we should discuss the

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3