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

Diff of /FigKernelPackages/FigGFF.pm

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

revision 1.14, Fri Sep 16 22:05:47 2005 UTC revision 1.21, Sun Feb 5 00:45:19 2006 UTC
# Line 1  Line 1 
1  #  #
2    # Copyright (c) 2003-2006 University of Chicago and Fellowship
3    # for Interpretations of Genomes. All Rights Reserved.
4    #
5    # This file is part of the SEED Toolkit.
6    #
7    # The SEED Toolkit is free software. You can redistribute
8    # it and/or modify it under the terms of the SEED Toolkit
9    # Public License.
10    #
11    # You should have received a copy of the SEED Toolkit Public License
12    # along with this program; if not write to the University of Chicago
13    # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14    # Genomes at veronika@thefig.info or download a copy from
15    # http://www.theseed.org/LICENSE.TXT.
16    #
17    
18    #
19  # FIG GFF utilities.  # FIG GFF utilities.
20  #  #
21    
# Line 12  Line 29 
29    
30  use base qw(Exporter);  use base qw(Exporter);
31  use vars qw(@EXPORT);  use vars qw(@EXPORT);
32  @EXPORT = qw(map_seed_alias_to_dbxref);  @EXPORT = qw(map_seed_alias_to_dbxref map_dbxref_to_seed_alias);
33    
34  #  #
35  # General GFF-related routines.  # General GFF-related routines.
# Line 57  Line 74 
74      {      {
75          return "NCBI_NP:$1";          return "NCBI_NP:$1";
76      }      }
77        elsif (/^NM_(\d+.*)/)
78        {
79            return "NCBI_NM:$1";
80        }
81      elsif (/^gi\|(\d+)/)      elsif (/^gi\|(\d+)/)
82      {      {
83          return "NCBI_gi:$1";          return "NCBI_gi:$1";
# Line 86  Line 107 
107      my($dbxref) = @_;      my($dbxref) = @_;
108    
109      # if it is not a valid xref just return it      # if it is not a valid xref just return it
110      return $dbxref unless (m/:/);      return $dbxref unless $dbxref =~ m/:/;
111    
112      my($type, $ref) = split(/:/, $dbxref, 2);      my($type, $ref) = split(/:/, $dbxref, 2);
113    
114      if ($type eq "NCBI_NP")      if (lc($type) eq "ncbi_np")
115        {
116            return "$ref";
117        }
118        elsif (lc($type) eq "ncbi_nm")
119      {      {
120          return "NP_$ref";          return "$ref";
121      }      }
122      elsif ($type eq "NCBI_gi")      elsif (lc($type) eq "ncbi_pid")
123        {
124            return "$ref";
125        }
126        elsif (lc($type) eq "ncbi_gi")
127      {      {
128          return "gi|$ref";          return "gi|$ref";
129      }      }
130      elsif ($type eq "KEGG")      elsif (lc($type) eq "kegg")
131      {      {
132          $ref =~ s/ /:/;          $ref =~ s/ /:/;
133          return "kegg|$ref";          return "kegg|$ref";
134      }      }
135      elsif ($type eq "UniProt")      elsif (lc($type) eq "uniprot")
136      {      {
137          return "uni|$ref";          return "uni|$ref";
138      }      }
139      elsif ($type eq "Swiss-Prot")      elsif (lc($type) eq "swiss-prot")
140      {      {
141          return "sp|$ref";          return "sp|$ref";
142      }      }
# Line 381  Line 410 
410                  chomp($addseq);                  chomp($addseq);
411                  $fastasequences .= ">$protein_id\n$addseq\n";                  $fastasequences .= ">$protein_id\n$addseq\n";
412    
413                  my $addseq = uc($fig->dna_seq($genome, @location));                  $addseq = uc($fig->dna_seq($genome, @location));
414                  $addseq =~ s/(.{$linelength})/$1\n/g; chomp($addseq);                  $addseq =~ s/(.{$linelength})/$1\n/g; chomp($addseq);
415    
416                  $fastasequences .= ">$cds_id\n$addseq\n";                  $fastasequences .= ">$cds_id\n$addseq\n";
# Line 611  Line 640 
640          # separately.          # separately.
641          #          #
642    
643    
644          if (/^>/)          if (/^>/)
645          {          {
646              $self->parse_fasta($fh, $_);              $self->parse_fasta($fh, $_);
# Line 631  Line 661 
661              #              #
662              next;              next;
663          }          }
664            elsif (/^\#$/)
665            {
666                #
667                # blank line starting with #
668                #
669                next;
670            }
671          elsif (/^\#\#(\S+)(?:\t(.*))?/)          elsif (/^\#\#(\S+)(?:\t(.*))?/)
672          {          {
673              #              #
# Line 786  Line 823 
823      {      {
824          my($name, $value) = split(/=/, $attr);          my($name, $value) = split(/=/, $attr);
825    
         warn "value before unescape: ", Dumper($value);  
826          my @values = map { uri_unescape($_) } split(/,/, $value);          my @values = map { uri_unescape($_) } split(/,/, $value);
         warn "values after unescape: ", Dumper(\@values);  
827    
828          # handle the aliases          # handle the aliases
829          if ($name eq "Alias") {          if ($name eq "Alias") {
# Line 868  Line 903 
903      my($self, $fh, $first_line) = @_;      my($self, $fh, $first_line) = @_;
904      my($cur, $cur_id);      my($cur, $cur_id);
905    
906      for ($_ = $first_line; $_;  $_ = <$fh>, chomp)      for ($_ = $first_line; defined($_);  $_ = <$fh>, chomp)
907      {      {
908          if (/^>\s*(\S+)/)          if (/^>\s*(\S+)/)
909          {          {

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3