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

Diff of /FigKernelPackages/FIG.pm

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

revision 1.445, Sat Feb 18 23:46:03 2006 UTC revision 1.446, Fri Feb 24 19:42:18 2006 UTC
# Line 14593  Line 14593 
14593      return $gg;      return $gg;
14594  }  }
14595    
14596    =head2 Markup Helper Methods
14597    
14598    This section contains the methods used to read and write Markup data. The
14599    markup data associates labels with sections of a feature's translation.
14600    
14601    In the SEED, Markup data is stored in a separate file for each marked feature
14602    in the the feature type subdirectory for an organism. So, for example, the
14603    PEG markups for C<fig|83333.1.peg.4> would be in the file
14604    
14605        FIG/Data/Organisms/83333.1/peg/markup4.tbl
14606    
14607    The file is stored in tab-separated form. Each line contains the following
14608    fields
14609    
14610    =over 4
14611    
14612    =item start
14613    
14614    1-based offset into the translation of the first amino acid to mark
14615    
14616    =item len
14617    
14618    number of amino acids to mark
14619    
14620    =item label
14621    
14622    label identifying the type of markup
14623    
14624    =back
14625    
14626    Reading and writing these tiny files is extremely fast, but they do have more
14627    overhead than would be expected if the data were stored in a single flat file
14628    managed by pointers from the FIG database. If that apprach becomes desirable,
14629    then only this section of FIG.pm needs to be changed.
14630    
14631    =cut
14632    
14633    #
14634    
14635    =head3 ReadMarkups
14636    
14637    C<< my $marks = $fig->ReadMarkups($fid); >>
14638    
14639    Read the markup data for the specified feature. The markings are returned as a
14640    list of triples. Each triple contains the start location of a markup, the
14641    length of the markup, and the label.
14642    
14643    =over 4
14644    
14645    =item fid
14646    
14647    ID of the feature whose markups are to be read.
14648    
14649    =item RETURN
14650    
14651    Returns a reference to list of 3-tuples. Each list element will consist of the
14652    starting offset of the markup (1-based), the length of the markup, and the label.
14653    All values are expressed in terms of distance into the protein translation of the
14654    feature.
14655    
14656    =back
14657    
14658    =cut
14659    #: Return Type $@@;
14660    sub ReadMarkups {
14661        # Get the parameters.
14662        my ($self, $fid) = @_;
14663        # Declare the return variable.
14664        my $retVal = [];
14665        # Get the name of the markup file.
14666        my $fname = _MarkupFileName($fid);
14667        # Get the contents of the file and parse it.
14668        if (-e $fname) {
14669            push @{$retVal}, map { [ Tracer::ParseRecord($_) ] } Tracer::GetFile($fname);
14670        }
14671        # Return the result.
14672        return $retVal;
14673    }
14674    
14675    =head3 WriteMarkups
14676    
14677    C<< $fig->WriteMarkups($fid, \@marks); >>
14678    
14679    Write out the markups for the specified feature. If the markup file for the
14680    specified feature does not exist, it will be created. If it does exist, it
14681    will be completely overwritten.
14682    
14683    =over 4
14684    
14685    =item fid
14686    
14687    ID of the feature whose markups are to be written
14688    
14689    =item marks
14690    
14691    Reference to a list of markups. Each markup is in the form of a 3-tuple consisting
14692    of the 1-based offset to the start of the markup, the length of the markup, and
14693    the markup label. The offset and length are specified in terms of the protein
14694    translation string.
14695    
14696    =back
14697    
14698    =cut
14699    #: Return Type ;
14700    sub WriteMarkups {
14701        # Get the parameters.
14702        my ($self, $fid, $marks) = @_;
14703        # Locate the output file.
14704        my $fname = _MarkupFileName($fid);
14705        # Open it for output.
14706        Open(\*OUTMARKS, ">$fname");
14707        # Write out the mark data.
14708        for my $mark (@{$marks}) {
14709            print OUTMARKS join("\t", @{$mark}) . "\n";
14710        }
14711        # Close the output file.
14712        close OUTMARKS;
14713    }
14714    
14715    =head3 _MarkupFileName
14716    
14717    C<< my $name = FIG::_MarkupFileName($fid); >>
14718    
14719    Return the name of the file containing the markup data for the specified feature.
14720    
14721    =over 4
14722    
14723    =item fid
14724    
14725    ID of the feature whose markup file is desired.
14726    
14727    =item RETURN
14728    
14729    Returns the full path of the file containing the feature markups for the feature desired.
14730    
14731    =back
14732    
14733    =cut
14734    #: Return Type $;
14735    sub _MarkupFileName {
14736        # Get the parameters.
14737        my ($fid) = @_;
14738        # Declare the return variable. We prime it with the organism directory.
14739        my $retVal = $FIG_Config::organisms;
14740        # Parse the feature ID.
14741        my ($genome, $type, $idx);
14742        if ($fid =~ /fig\|(\d+\.\d+)\.([a-z]+)\.(\d+)/) {
14743            ($genome, $type, $idx) = ($1,$2,$3);
14744        } else {
14745            Confess("Invalid feature ID $fid specified in Markup call.");
14746        }
14747        # Compute the file name from the pieces of the feature ID.
14748        $retVal .= "/$genome/Features/$type/markup$idx.tbl";
14749        # Return the result.
14750        return $retVal;
14751    }
14752    
14753  =head2 UserData Helper Methods  =head2 UserData Helper Methods
14754    

Legend:
Removed from v.1.445  
changed lines
  Added in v.1.446

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3