[Bio] / FigKernelPackages / raelib.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/raelib.pm

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

revision 1.7, Sun Apr 3 02:15:15 2005 UTC revision 1.16, Wed May 25 00:49:39 2005 UTC
# Line 2  Line 2 
2    
3  =pod  =pod
4    
5  =head1  =head1 RAE Library
6    
7   Some routines and things that Rob uses. Please feel free to use at will and incorporate into   Some routines and things that Rob uses. Please feel free to use at will and incorporate into
8   your own code or move them into FIG.pm or elsewhere.   your own code or move them into FIG.pm or elsewhere.
# Line 75  Line 75 
75    
76   The correspondence has PIR ID \t FIG ID\n, and is probably based on ftp://ftp.pir.georgetown.edu/pir_databases/pirsf/data/pirsfinfo.dat   The correspondence has PIR ID \t FIG ID\n, and is probably based on ftp://ftp.pir.georgetown.edu/pir_databases/pirsf/data/pirsfinfo.dat
77    
78     This method takes three arguments:
79       from    : pirsfinfo.dat file
80       to      : file to write information to
81       verbose : report on progress
82    
83     Returns the number of lines in the pirsinfo file that were read.
84    
85  =cut  =cut
86    
87  sub pirsfcorrespondence {  sub pirsfcorrespondence {
88   my ($self, $from, $to)=@_;   my ($self, $from, $to, $verbose)=@_;
89   die "File $from does not exist as called in $0" unless (-e $from);   unless (-e $from) {
90      print STDERR "File $from does not exist as called in $0\n";
91      return 0;
92     }
93   open (IN, $from) || die "Can't open $from";   open (IN, $from) || die "Can't open $from";
94   open (OUT, ">$to") || die "Can't write tot $to";   open (OUT, ">$to") || die "Can't write to $to";
95     my $linecount;
96   while (<IN>) {   while (<IN>) {
97      $linecount++;
98      if ($verbose && !($linecount % 10000))  {print STDERR "Parsed $linecount lines\n"}
99    if (/^>/) {print OUT; next}    if (/^>/) {print OUT; next}
100    chomp;    chomp;
101    my $done;    foreach my $peg ($self->swiss_pir_ids($_)) {
   foreach my $peg ($fig->by_alias("uni|$_")) {  
102     print OUT $_, "\t", $peg, "\n";     print OUT $_, "\t", $peg, "\n";
    $done=1;  
103    }    }
   unless ($done) {print OUT $_, "\t\n"}  
104   }   }
105   close IN;   close IN;
106   close OUT;   close OUT;
107     return $linecount;
108  }  }
109    
110    =head2 uniprotcorrespondence
111    
112    Generate a correspondence table between uniprot knowledge base IDs and FIG ID's.
113    
114    The uniprot KB file is in the form:  UniProtKB_Primary_Accession | UniProtKB_ID | Section | Protein Name
115    
116     This method takes three arguments:
117       from    : uniprotKB file
118       to      : file to write information to
119       verbose : report on progress
120    
121     Returns the number of lines in the pirsinfo file that were read.
122    
123    =cut
124    
125    sub uniprotcorrespondence {
126     my ($self, $from, $to, $verbose)=@_;
127     unless (-e $from) {
128      print STDERR "File $from does not exist as called in $0\n";
129      return 0;
130     }
131     open (IN, $from) || die "Can't open $from";
132     open (OUT, ">$to") || die "Can't write to $to";
133     my $linecount;
134     while (<IN>) {
135      chomp;
136      $linecount++;
137      if ($verbose && !($linecount % 10000))  {print STDERR "Parsed $linecount lines\n"}
138      my @line=split /\s+\|\s+/;
139      my $added;
140      foreach my $peg ($self->swiss_pir_ids($line[0])) {
141       print OUT "$_ | $peg\n";
142       $added=1;
143      }
144      unless ($added) {print OUT "$_\n"}
145     }
146     close IN;
147     close OUT;
148     return $linecount;
149    }
150    
151    
152    
153    =head2 swiss_pir_ids()
154    
155    SwissProt/PIR have lots of ID's that we want to get, usually in this order - uni --> tr --> sp. This routine will map swissprot/pir ids to fig id's.
156    
157    =cut
158    
159    sub swiss_pir_ids {
160     my ($self, $id)=@_;
161     return () unless ($id);
162    
163     my @return=($fig->by_alias("uni|$id"));
164     return @return if ($return[0]);
165    
166     @return=($fig->by_alias("tr|$id"));
167     return @return if ($return[0]);
168    
169     @return=($fig->by_alias("sp|$id"));
170     return @return if ($return[0]);
171    
172     return ();
173    }
174    
175  =head2 ss_by_id  =head2 ss_by_id
176    
# Line 173  Line 248 
248   my @return;   my @return;
249   my @attr=$fig->feature_attributes($peg);   my @attr=$fig->feature_attributes($peg);
250   foreach my $attr (@attr) {   foreach my $attr (@attr) {
251    my ($gottag, $val, $link)=@$attr;    my ($gotpeg, $gottag, $val, $link)=@$attr;
252    push @return, $val if ($gottag eq $tag);    push @return, $val if ($gottag eq $tag);
253   }   }
254   return wantarray ? @return : join "; ", @return;   return wantarray ? @return : join "; ", @return;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.16

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3