[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.105, Wed Jan 30 22:14:02 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 267  Line 270 
270              Trace("No load file found for $tableName in $dataDir.") if T(0);              Trace("No load file found for $tableName in $dataDir.") if T(0);
271          } else {          } else {
272              # Attempt to load this table.              # Attempt to load this table.
273              my $result = $self->LoadTable($fileName, $tableName, $truncateFlag);              my $result = $self->LoadTable($fileName, $tableName, truncate => $truncateFlag);
274              # Accumulate the resulting statistics.              # Accumulate the resulting statistics.
275              $retVal->Accumulate($result);              $retVal->Accumulate($result);
276          }          }
# Line 3039  Line 3042 
3042          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",          my ($taxonomy) = $self->GetFlat(['IsLocatedIn', 'HasContig', 'Genome'], "IsLocatedIn(from-link) = ?",
3043                                          [$fid], 'Genome(taxonomy)');                                          [$fid], 'Genome(taxonomy)');
3044          # Add this feature to the hash buffer.          # Add this feature to the hash buffer.
3045          Tracer::AddToListMap(\%hashBuffer, $taxonomy, $fid);          push @{$hashBuffer{$taxonomy}}, $fid;
3046      }      }
3047      # Sort the keys and get the elements.      # Sort the keys and get the elements.
3048      my @retVal = ();      my @retVal = ();
# Line 3625  Line 3628 
3628          # Get the super-group name.          # Get the super-group name.
3629          my $realGroupID;          my $realGroupID;
3630          if ($groupID =~ /([A-Z]\w+)/) {          if ($groupID =~ /([A-Z]\w+)/) {
             my $sortOfGroup = $1;  
3631              if (! defined($superTable{$1})) {              if (! defined($superTable{$1})) {
3632                  Confess("Super-group name not found for group $groupID.");                  Confess("Super-group name not found for group $groupID.");
3633              } else {              } else {
3634                  $realGroupID = $superTable{$1}->{superGroup};                  $realGroupID = $1;
3635              }              }
3636          } else {          } else {
3637              Confess("Invalid group name $groupID.");              Confess("Invalid group name $groupID.");
# Line 3670  Line 3672 
3672      # Check for the group file data.      # Check for the group file data.
3673      my %superTable = $self->CheckGroupFile();      my %superTable = $self->CheckGroupFile();
3674      # Compute the real group name.      # Compute the real group name.
     my ($realGroup, $pageLink);  
3675      if ($group =~ /([A-Z]\w+)/) {      if ($group =~ /([A-Z]\w+)/) {
3676          my $sortOfGroup = $1;          my $realGroup = $1;
3677          if (! defined($superTable{$1})) {          if (! defined($superTable{$1})) {
3678              Confess("No sort-of group found for \"$group\".");              Confess("No super-group found for \"$group\".");
3679          } else {          } else {
3680              $pageLink = $superTable{$1}->{page};              $retVal = "../content/$superTable{$1}->{page}";
3681          }          }
3682      } else {      } else {
3683          Confess("\"group\" is not a valid group name.");          Confess("\"group\" is not a valid group name.");
3684      }      }
     # Return the page name.  
     $retVal = "../content/" . $pageLink;  
3685      # Return the result.      # Return the result.
3686      return $retVal;      return $retVal;
3687  }  }
# Line 3725  Line 3724 
3724    
3725  Get the group file hash. The group file hash describes the relationship  Get the group file hash. The group file hash describes the relationship
3726  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
3727  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
3728  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
3729  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.
3730  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
3731  display page for the super-group.  of C<0> implies an entire genus.
3732    
3733  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
3734  resulting hash reference contains the following fields.  resulting hash reference contains the following fields.
3735    
3736  =over 4  =over 4
3737    
 =item superGroup  
   
 Super-group name.  
   
3738  =item page  =item page
3739    
3740  The super-group's web page in the NMPDR.  The super-group's web page in the NMPDR.
3741    
3742  =item genus  =item contents
   
 The genus of the sort-of group.  
   
 =item species  
3743    
3744  A reference to a list of the species for the sort-of group.  A list of 2-tuples, each containing a genus name followed by a species name
3745    (or 0, indicating all species). This list indicates which organisms belong
3746    in the super-group.
3747    
3748  =back  =back
3749    
# Line 3767  Line 3760 
3760          my @groupLines = Tracer::GetFile("$FIG_Config::sproutData/groups.tbl");          my @groupLines = Tracer::GetFile("$FIG_Config::sproutData/groups.tbl");
3761          # Loop through the list of sort-of groups.          # Loop through the list of sort-of groups.
3762          for my $groupLine (@groupLines) {          for my $groupLine (@groupLines) {
3763              my ($mainName, $name, $page, $genus, $species) = split(/\t/, $groupLine);              my ($name, $page, @contents) = split /\t/, $groupLine;
3764              $groupHash{$name} = { page => $page,              $groupHash{$name} = { page => $page,
3765                                 genus => $genus,                                    contents => [ map { [ split /\s*,\s*/, $_ ] } @contents ]
3766                                 species => [ split(/\s*,\s*/, $species) ],                                  };
                                superGroup => $mainName };  
3767          }          }
3768          # Save the hash.          # Save the hash.
3769          $self->{groupHash} = \%groupHash;          $self->{groupHash} = \%groupHash;

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3