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

View of /FigKernelPackages/AttributeTransactions.pm

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.5 - (download) (as text) (annotate)
Thu Sep 1 09:35:43 2005 UTC (14 years, 7 months ago) by parrello
Branch: MAIN
Changes since 1.4: +0 -0 lines
Cleaned up the transaction-processing stuff.

#!/usr/bin/perl -w

package AttributeTransactions;

    use TransactionProcessor;
    @ISA = ('TransactionProcessor');

    use strict;
    use Tracer;
    use PageBuilder;
    use FIG;

=head1 Attribute Transactions

=head2 Introduction

This is a TransactionProcessor subclass that copies the attributes for the changed

=head2 Methods

=head3 new

C<< my $xprc = AttributeTransactions->new(\%options, $command, $directory, $idFile); >>

Construct a new AttributeTransactions object.

=over 4

=item options

Reference to a hash table containing the command-line options.

=item command

Command specified on the B<TransactFeatures> command line. This command determines
which TransactionProcessor subclass is active.

=item directory

Directory containing the transaction files.

=item idFile

Name of the ID file (if needed).



sub new {
    # Get the parameters.
    my ($class, $options, $command, $directory, $idFile) = @_;
    # Check to see if we're supposed to check or apply.
    $options->{fix} = ($command eq 'attribute');
    # Construct via the subclass.
    return TransactionProcessor::new($class, $options, $command, $directory, $idFile);

=head3 Setup

C<< $xprc->Setup(); >>

Set up to attribute the transactions. This includes reading the ID file.

#: Return Type ;
sub Setup {
    # Get the parameters.
    my ($self) = @_;
    # Read the ID hash from the ID file.

=head3 SetupGenome

C<< $xprc->SetupGenome(); >>

Set up for processing this genome. All we really need to do here is add
counters to the statistics object.

#: Return Type ;
sub SetupGenome {
    # Get the parameters.
    my ($self) = @_;
    # Create the statistic names.

=head3 Change

C<< $xprc->Change($fid, $newID, $locations, $aliases, $translation); >>

Replace a feature in the data store. We copy the attributes from the old feature
ID to the new one.

=over 4

=item fid

ID of the feature being changed.

=item newID

New ID to give to the feature.

=item locations

New location to give to the feature, in the form of a comma-separated list of location
strings in SEED format.

=item aliases (optional)

A new list of alias names for the feature.

=item translation (optional)

New protein translation string for the feature. If this field is omitted and
the feature is a peg, the translation will be generated by normal means.



sub Change {
    my ($self, $fid, $newID, $locations, $aliases, $translation) = @_;
    my $fig = $self->{fig};
    # Extract the feature type and ordinal number from the new ID.
    my ($ftype, $ordinal, $key) = $self->ParseNewID($newID);
    # Get the real ID.
    my $realID = $self->GetRealID($ordinal, $key);
    # Delete any existing attributes on the target.
    my @obsoleteAttributes = $fig->get_attributes($realID);
    for my $attribute (@obsoleteAttributes) {
        # The attribute descriptor is actually a four-tuple, but we
        # only need the first three.
        my ($oldID, $key, $value) = @{$attribute};
        # Check to see if we're really doing this.
        if ($self->Option('fix')) {
            # Go ahead and do it.
            $fig->delete_attribute($realID, $key, $value);
        } else {
            # Just trace it.
            Trace("Attribute $key would be cleaned from $realID.") if T(4);
    # Get the old attributes.
    my @attributes = $fig->get_attributes($fid);
    # Loop through the attributes, adding them to the replacement feature.
    for my $attribute (@attributes) {
        # The attribute descriptor is actually a four-tuple.
        my ($oldID, $key, $value, $url) = @{$attribute};
        # Check to see if we're really doing this.
        if ($self->Option('fix')) {
            # Go ahead and do it.
            $fig->add_attribute($realID, $key, $value, $url);
        } else {
            # Just trace it.
            Trace("Attribute $key would be moved to $realID.") if T(4);
        # Record this operation.


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3