[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.80, Thu Aug 10 07:34:37 2006 UTC revision 1.83, Wed Sep 6 19:30:22 2006 UTC
# Line 3400  Line 3400 
3400      return $retVal;      return $retVal;
3401  }  }
3402    
3403    =head3 Fix
3404    
3405    C<< my %fixedHash = Sprout::Fix(%groupHash); >>
3406    
3407    Prepare a genome group hash (like that returned by L</GetGroups> for processing.
3408    Groups with the same primary name will be combined. The primary name is the
3409    first capitalized word in the group name.
3410    
3411    =over 4
3412    
3413    =item groupHash
3414    
3415    Hash to be fixed up.
3416    
3417    =item RETURN
3418    
3419    Returns a fixed-up version of the hash.
3420    
3421    =back
3422    
3423    =cut
3424    
3425    sub Fix {
3426        # Get the parameters.
3427        my (%groupHash) = @_;
3428        # Create the result hash.
3429        my %retVal = ();
3430        # Copy over the genomes.
3431        for my $groupID (keys %groupHash) {
3432            # Make a safety copy of the group ID.
3433            my $realGroupID = $groupID;
3434            # Yank the primary name.
3435            if ($groupID =~ /([A-Z]\w+)/) {
3436                $realGroupID = $1;
3437            }
3438            # Append this group's genomes into the result hash.
3439            Tracer::AddToListMap(\%retVal, $realGroupID, @{$groupHash{$groupID}});
3440        }
3441        # Return the result hash.
3442        return %retVal;
3443    }
3444    
3445    =head3 ReadGroupFile
3446    
3447    C<< my %groupData = Sprout::ReadGroupFile($groupFileName); >>
3448    
3449    Read in the data from the specified group file. The group file contains information
3450    about each of the NMPDR groups.
3451    
3452    =over 4
3453    
3454    =item name
3455    
3456    Name of the group.
3457    
3458    =item page
3459    
3460    Name of the group's page on the web site (e.g. C<campy.php> for
3461    Campylobacter)
3462    
3463    =item genus
3464    
3465    Genus of the group
3466    
3467    =item species
3468    
3469    Species of the group, or an empty string if the group is for an entire
3470    genus. If the group contains more than one species, the species names
3471    should be separated by commas.
3472    
3473    =back
3474    
3475    The parameters to this method are as follows
3476    
3477    =over 4
3478    
3479    =item groupFile
3480    
3481    Name of the file containing the group data.
3482    
3483    =item RETURN
3484    
3485    Returns a hash keyed on group name. The value of each hash
3486    
3487    =back
3488    
3489    =cut
3490    
3491    sub ReadGroupFile {
3492        # Get the parameters.
3493        my ($groupFileName) = @_;
3494        # Declare the return variable.
3495        my %retVal;
3496        # Read the group file.
3497        my @groupLines = Tracer::GetFile($groupFileName);
3498        for my $groupLine (@groupLines) {
3499            my ($name, $page, $genus, $species) = split(/\t/, $groupLine);
3500            $retVal{$name} = [$page, $genus, $species];
3501        }
3502        # Return the result.
3503        return %retVal;
3504    }
3505    
3506  =head2 Internal Utility Methods  =head2 Internal Utility Methods
3507    
3508  =head3 ParseAssignment  =head3 ParseAssignment
# Line 3456  Line 3559 
3559      }      }
3560      # If we have an assignment, we need to clean the function text. There may be      # If we have an assignment, we need to clean the function text. There may be
3561      # extra junk at the end added as a note from the user.      # extra junk at the end added as a note from the user.
3562      if (@retVal > 1) {      if (defined( $retVal[1] )) {
3563          $retVal[1] =~ s/(\t\S)?\s*$//;          $retVal[1] =~ s/(\t\S)?\s*$//;
3564      }      }
3565      # Return the result list.      # Return the result list.

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.83

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3