[Bio] / Sprout / Sprout.pm Repository:
ViewVC logotype

Diff of /Sprout/Sprout.pm

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

revision 1.102, Thu Dec 6 14:56:23 2007 UTC revision 1.107, Thu Feb 7 00:06:16 2008 UTC
# Line 78  Line 78 
78    
79  * B<noDBOpen> suppresses the connection to the database if TRUE, else FALSE  * B<noDBOpen> suppresses the connection to the database if TRUE, else FALSE
80    
81    * B<host> name of the database host
82    
83  =back  =back
84    
85  For example, the following constructor call specifies a database named I<Sprout> and a user name of  For example, the following constructor call specifies a database named I<Sprout> and a user name of
86  I<fig> with a password of I<admin>. The database load files are in the directory  I<fig> with a password of I<admin>. The database load files are in the directory
87  F</usr/fig/SproutData>.  F</usr/fig/SproutData>.
88    
89      my $sprout = Sprout->new('Sprout', { userData =>; 'fig/admin', dataDir => '/usr/fig/SproutData' });      my $sprout = Sprout->new('Sprout', { userData => 'fig/admin', dataDir => '/usr/fig/SproutData' });
90    
91  =cut  =cut
92    
# Line 108  Line 110 
110                         port         => $FIG_Config::dbport,                         port         => $FIG_Config::dbport,
111                                                          # database connection port                                                          # database connection port
112                         sock         => $FIG_Config::dbsock,                         sock         => $FIG_Config::dbsock,
113                         host         => $FIG_Config::dbhost,                         host         => $FIG_Config::sprout_host,
114                         maxSegmentLength => 4500,        # maximum feature segment length                         maxSegmentLength => 4500,        # maximum feature segment length
115                         maxSequenceLength => 8000,       # maximum contig sequence length                         maxSequenceLength => 8000,       # maximum contig sequence length
116                         noDBOpen     => 0,               # 1 to suppress the database open                         noDBOpen     => 0,               # 1 to suppress the database open
# Line 121  Line 123 
123      # Connect to the database.      # Connect to the database.
124      my $dbh;      my $dbh;
125      if (! $optionTable->{noDBOpen}) {      if (! $optionTable->{noDBOpen}) {
126            Trace("Connect data: host = $optionTable->{host}, port = $optionTable->{port}.") if T(3);
127          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,          $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName,
128                                  $password, $optionTable->{port}, $optionTable->{host}, $optionTable->{sock});                                  $password, $optionTable->{port}, $optionTable->{host}, $optionTable->{sock});
129      }      }
# Line 147  Line 150 
150      return $retVal;      return $retVal;
151  }  }
152    
153    =head3 RealCoreGenomes
154    
155        my @genomes = $sprout->RealCoreGenomes();
156    
157    Return the IDs of the original core NMPDR genomes. These are the ones
158    in the major groups indicated in the C<$realCoreGroups> member of the
159    B<FIG_Config> file.
160    
161    =cut
162    
163    sub RealCoreGenomes {
164        # Get the parameters.
165        my ($self) = @_;
166        # Declare the return variable.
167        my @retVal = ();
168        # Get the hash of all the genome groups.
169        my %groups = $self->GetGroups();
170        # Loop through the groups, keeping the ones that belong to real core
171        # organisms.
172        for my $group (keys %groups) {
173            if (grep { $group =~ /$_/ } @{$FIG_Config::realCoreGroups}) {
174                push @retVal, @{$groups{$group}};
175            }
176        }
177        # Return the result.
178        return @retVal;
179    }
180    
181  =head3 MaxSegment  =head3 MaxSegment
182    
183      my $length = $sprout->MaxSegment();      my $length = $sprout->MaxSegment();
# Line 267  Line 298 
298              Trace("No load file found for $tableName in $dataDir.") if T(0);              Trace("No load file found for $tableName in $dataDir.") if T(0);
299          } else {          } else {
300              # Attempt to load this table.              # Attempt to load this table.
301              my $result = $self->LoadTable($fileName, $tableName, $truncateFlag);              my $result = $self->LoadTable($fileName, $tableName, truncate => $truncateFlag);
302              # Accumulate the resulting statistics.              # Accumulate the resulting statistics.
303              $retVal->Accumulate($result);              $retVal->Accumulate($result);
304          }          }
# Line 3039  Line 3070 
3070          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",
3071                                          [$fid], 'Genome(taxonomy)');                                          [$fid], 'Genome(taxonomy)');
3072          # Add this feature to the hash buffer.          # Add this feature to the hash buffer.
3073          Tracer::AddToListMap(\%hashBuffer, $taxonomy, $fid);          push @{$hashBuffer{$taxonomy}}, $fid;
3074      }      }
3075      # Sort the keys and get the elements.      # Sort the keys and get the elements.
3076      my @retVal = ();      my @retVal = ();
# Line 3625  Line 3656 
3656          # Get the super-group name.          # Get the super-group name.
3657          my $realGroupID;          my $realGroupID;
3658          if ($groupID =~ /([A-Z]\w+)/) {          if ($groupID =~ /([A-Z]\w+)/) {
             my $sortOfGroup = $1;  
3659              if (! defined($superTable{$1})) {              if (! defined($superTable{$1})) {
3660                  Confess("Super-group name not found for group $groupID.");                  Confess("Super-group name not found for group $groupID.");
3661              } else {              } else {
3662                  $realGroupID = $superTable{$1}->{superGroup};                  $realGroupID = $1;
3663              }              }
3664          } else {          } else {
3665              Confess("Invalid group name $groupID.");              Confess("Invalid group name $groupID.");
# Line 3670  Line 3700 
3700      # Check for the group file data.      # Check for the group file data.
3701      my %superTable = $self->CheckGroupFile();      my %superTable = $self->CheckGroupFile();
3702      # Compute the real group name.      # Compute the real group name.
     my ($realGroup, $pageLink);  
3703      if ($group =~ /([A-Z]\w+)/) {      if ($group =~ /([A-Z]\w+)/) {
3704          my $sortOfGroup = $1;          my $realGroup = $1;
3705          if (! defined($superTable{$1})) {          if (! defined($superTable{$1})) {
3706              Confess("No sort-of group found for \"$group\".");              Confess("No super-group found for \"$group\".");
3707          } else {          } else {
3708              $pageLink = $superTable{$1}->{page};              $retVal = "../content/$superTable{$1}->{page}";
3709          }          }
3710      } else {      } else {
3711          Confess("\"group\" is not a valid group name.");          Confess("\"group\" is not a valid group name.");
3712      }      }
     # Return the page name.  
     $retVal = "../content/" . $pageLink;  
3713      # Return the result.      # Return the result.
3714      return $retVal;      return $retVal;
3715  }  }
# Line 3725  Line 3752 
3752    
3753  Get the group file hash. The group file hash describes the relationship  Get the group file hash. The group file hash describes the relationship
3754  between a group and the super-group to which it belongs for purposes of  between a group and the super-group to which it belongs for purposes of
3755  display. The super-group name is computed from the sort-of group name,  display. The super-group name is computed from the first capitalized word
3756  which is the first capitalized word in the actual group name. For each  in the actual group name. For each super-group, the group file contains
3757  sort-of group, the group file contains the super-group name, the group  the page name and a list of the species expected to be in the group.
3758  genus, the list of applicable species (if any), and the name of the NMPDR  Each species is specified by a genus and a species name. A species name
3759  display page for the super-group.  of C<0> implies an entire genus.
3760    
3761  This method returns a hash from sort-of group names to hash reference. Each  This method returns a hash from super-group names to a hash reference. Each
3762  resulting hash reference contains the following fields.  resulting hash reference contains the following fields.
3763    
3764  =over 4  =over 4
3765    
 =item superGroup  
   
 Super-group name.  
   
3766  =item page  =item page
3767    
3768  The super-group's web page in the NMPDR.  The super-group's web page in the NMPDR.
3769    
3770  =item genus  =item contents
   
 The genus of the sort-of group.  
3771    
3772  =item species  A list of 2-tuples, each containing a genus name followed by a species name
3773    (or 0, indicating all species). This list indicates which organisms belong
3774  A reference to a list of the species for the sort-of group.  in the super-group.
3775    
3776  =back  =back
3777    
# Line 3767  Line 3788 
3788          my @groupLines = Tracer::GetFile("$FIG_Config::sproutData/groups.tbl");          my @groupLines = Tracer::GetFile("$FIG_Config::sproutData/groups.tbl");
3789          # Loop through the list of sort-of groups.          # Loop through the list of sort-of groups.
3790          for my $groupLine (@groupLines) {          for my $groupLine (@groupLines) {
3791              my ($mainName, $name, $page, $genus, $species) = split(/\t/, $groupLine);              my ($name, $page, @contents) = split /\t/, $groupLine;
3792              $groupHash{$name} = { page => $page,              $groupHash{$name} = { page => $page,
3793                                 genus => $genus,                                    contents => [ map { [ split /\s*,\s*/, $_ ] } @contents ]
3794                                 species => [ split(/\s*,\s*/, $species) ],                                  };
                                superGroup => $mainName };  
3795          }          }
3796          # Save the hash.          # Save the hash.
3797          $self->{groupHash} = \%groupHash;          $self->{groupHash} = \%groupHash;

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.107

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3