[Bio] / FigWebServices / figfam_server.cgi Repository:
ViewVC logotype

Annotation of /FigWebServices/figfam_server.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : disz 1.1 use strict;
2 :     use FIG;
3 :     use CGI;
4 :     use Data::Dumper;
5 :     use FFs;
6 :     use FF;
7 :     use Kmers;
8 :    
9 :     my $kmerDB = "/home/overbeek/Proj/MotifFF/Rel9/10mers/kmer.db";
10 :     my $friDB = "/home/overbeek/Proj/MotifFF/Rel9/10mers/FRI.db";
11 :     my $binDB = "/scratch/olson/table.rel9+sims.Apr25";
12 :     my $kmers = Kmers->new_using_C($binDB, $friDB);
13 :     my $kmers_ross = new Kmers($kmerDB, $friDB);
14 :    
15 :     my $cgi = new CGI;
16 :     my $fig = new FIG;
17 :     my $ffs = new FFs("$FIG_Config::FigfamsData");
18 :     my $function = $cgi->param('function');
19 :     $function or myerror($cgi, "500 missing argument", "missing function argument");
20 :    
21 :     #
22 :     #The FIGfam server processes requests of the form:
23 :     #
24 :     # 1. PLACE-IN-FAMILY takes as input a list of protein sequences. It
25 :     # returns a list where each element describes the outcome of
26 :     # trying to place the corresponding input sequence into a
27 :     # FIGfam. Each output can be either
28 :     #
29 :     # COULD-NOT-PLACE-IN-FAMILY
30 :     # or
31 :     # ID FUNCTION
32 :     #
33 :     # where ID is of the form FIGxxxxxx and FUNCTION is the family
34 :     # function.
35 :     #
36 :     # 2. MEMBERS-OF-FAMILIES takes as input a list of FIGfam IDs. The
37 :     # output is a list of functions for those families
38 :     # (INVALID-FAMILY will be returned for IDs that do not correspond
39 :     # to an active family), as well as a list of the IDs in each family.
40 :     #
41 :     # 3. SHOULD-BE-MEMBER takes as input a list of 2-tuples
42 :     #
43 :     # [FIGfam-ID,protein sequence]
44 :     #
45 :     # It returns a list of boolean values indicating whether or not
46 :     # the indicated protein sequence can be placed in the designated
47 :     # family.
48 :     #
49 :     # 4. ALL-FAMILIES returns a list of [FIGfam-ID,function] tuples.
50 :     #
51 :     #
52 :     # 5. ASSIGN-FUNCTION-TO-PROT is similar to PLACE-IN-FAMILY, except
53 :     # that the returned list contains either
54 :     #
55 :     # COULD-NOT-PLACE-IN-FAMILY
56 :     # or
57 :     # ID FUNCTION
58 :     #
59 :     # That is, it does not indicate which FIGfam was used to
60 :     # determine the function. This allows higher-performance
61 :     # alternatives for cases in which multiple FIGfams implement the
62 :     # same function. The algorithm supported utilizes the underlying
63 :     # FIGfams, but characterizes sets that implement the same
64 :     # function and does not support distinguishing which FIGfam
65 :     # is actually the right subgrouping.
66 :     #
67 :     # 6. ASSIGN-FUNCTIONS-TO-DNA takes as input a list of DNA
68 :     # sequences. It returns a list where each element describes
69 :     # a region of DNA that is believed to be part of a gene encoding
70 :     # a protein sequence that would be placed into a FIGfam
71 :     # successfully, if the whole protein sequence could be
72 :     # determined. That is, the returned list will contain entrties
73 :     # of either the form
74 :     #
75 :     # COULD-NOT-PLACE-ANY-REGIONS-IN-FAMILIES
76 :     # or
77 :     # BEGIN1 END1 FUNCTION1 BEGIN2 END2 FUNCTION2 ...
78 :     #
79 :     # where BEGIN and END specify a region (if BEGIN is greater than
80 :     # END, the region described is on the reverse strand) and
81 :     # FUNCTION is the family function of the protein sequence that is
82 :     # believed to be encoded by DNA including the embedded region.
83 :     # Each input sequence can produce an arbitrary number of matched
84 :     # regions, there will be 3 fields for each matched region. Note
85 :     # that the described region may include frameshifts and embedded
86 :     # stop codons. The algorithm seeking meaningful sections of DNA
87 :     # assumes that it may have an incomplete, low-quality sequence
88 :     # (and uses an algorithm that attempts to locate meaningful
89 :     # matches even so).
90 :    
91 :    
92 :     print $cgi->header();
93 :    
94 :     if ($function eq "members_of_families") {
95 :     my @id = $cgi->param('id');
96 :     @id or myerror($cgi, "500 missing id", "figfam server missing id argument");
97 :     foreach my $famid (@id) {
98 :     my $fam = new FF($famid, $ffs->{dir});
99 :     if ($fam) {
100 :     print $famid, " ", $fam->family_function(), "\n";
101 :     print join("\n", $fam->list_members()), "\n";
102 :     } else {
103 :     print "$famid INVALID-FAMILY\n";
104 :     }
105 :     }
106 :    
107 :     } elsif ($function eq "should_be_member") {
108 :     my @id = $cgi->param('id_seq');
109 :     @id or myerror($cgi, "500 missing id_seq", "figfam server missing id_seq argument");
110 :     foreach my $parm (@id) {
111 :     my ($famid, $seq) = split /,/, $parm;
112 :     my $fam = new FF($famid, $ffs->{dir});
113 :     if ($fam) {
114 :     my ($bool, $sims) = $fam->should_be_member($seq), "\n";
115 :     print $bool?1:0, "\n";
116 :     } else {
117 :     print "INVALID-FAMILY\t$famid\n";
118 :     }
119 :     }
120 :    
121 :     } elsif ($function eq "all_families") {
122 :     print join("\n", $ffs->all_families(1)), "\n";
123 :    
124 :     } elsif ($function eq "place_in_family") {
125 :     my @id = $cgi->param('id_seq');
126 :     @id or myerror($cgi, "500 missing seq", "figfam server missing seq argument");
127 :     foreach my $parm (@id) {
128 :     my ($id, $seq) = split /,/, $parm;
129 :     print "\n$seq\n";
130 :     my ($fam) = $ffs->place_in_family($seq);
131 :     if ($fam) {
132 :     print "$id\t$fam->{id}\t$fam->{function}\n";
133 :     } else {
134 :     print "COULD-NOT-PLACE-IN_FAMILY\n";
135 :     }
136 :     }
137 :    
138 :     } elsif ($function eq "assign_function_to_prot") {
139 :     my @id = $cgi->param('id_seq');
140 :     @id or myerror($cgi, "500 missing id_seq", "figfam server missing id_seq argument");
141 :     foreach my $parm (@id) {
142 :     my ($id, $seq) = split /,/, $parm;
143 :     my $func = $kmers->assign_function_to_prot($seq);
144 :     if ($func) {
145 :     print "$id\t$func\n";
146 :     } else {
147 :     print "$id\tCOULD-NOT-PLACE\n";
148 :     }
149 :     }
150 :     } elsif ($function eq "assign_function_to_DNA") {
151 :     my @id = $cgi->param('id_seq');
152 :     @id or myerror($cgi, "500 missing id_seq", "figfam server missing id_seq argument");
153 :     foreach my $parm (@id) {
154 :     my ($id, $seq) = split /,/, $parm;
155 :     my @hits = $kmers->assign_functions_to_DNA($seq);
156 :     foreach my $hit (@hits) {
157 :     my ($b,$e,$func) = @$hit;
158 :     print join("\t",($id,join("_",($id,$b,$e)),$func)),"\n";
159 :     }
160 :     # print "Ross\n";
161 :     # my @hits = $kmers_ross->assign_functions_to_DNA($seq);
162 :     # foreach my $hit (@hits) {
163 :     # my ($b,$e,$func) = @$hit;
164 :     # print join("\t",($id,join("_",($id,$b,$e)),$func)),"\n";
165 :     # }
166 :     }
167 :     } else {
168 :     myerror($cgi, "500 bad function argument $function", "usage:figfam function=[place_in_family | members_of_families | should_be_member | all_families");
169 :     }
170 :    
171 :     sub myerror
172 :     {
173 :     my($cgi, $stat, $msg) = @_;
174 :     print $cgi->header(-status => $stat);
175 :    
176 :     print "$msg\n";
177 :     exit;
178 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3