SeqDiff - A tool to find the differences between two Seq objects.
# use the package use SeqDiff; # get some SeqI objects from somewhere (GenBank/RefSeq/...) my $old_seq; # a Bio::SeqI implementing object my $new_seq; # a Bio::SeqI implementing object # get a new instance my $seqdiff = SeqDiff->new( -old => $old_seq, -new => $new_seq, ); # match the features $seqdiff->match_features(); # loop through the pairs of matching features and compare while ( my $diff = $seqdiff->next() ) { next unless ref $diff; # do something with $diff } # get whatever features were 'lost' or 'gained my @lost = $seqdiff->get_lost_features(); my @gained = $sefdiff->get_gained_features();
The SeqDiff tool presented here will compare two Bio::Seq objects. It first looks through both objects and matches their features based on some criteria. It then recursively compares each pair of features and returns the comparison.
Originally the package calculated the differences for all the features instantly (in memory.) This caused a problem for Seq objects that have large numbers of features. Now the SeqDiff object has a method called next() that should be used to iterate through the comparisons.
This package was developed specifically for comparing the file- histories of GenBank/RefSeq files....what changed from one version to the next?
The new() method constructs a new SeqDiff object. The returned object can be used to retreive differences between the two SeqI objects given to it.
A Bio::SeqI implementing object. This is considered to be a representation of the data that existed earlier in time.
Another Bio::SeqI implementing object. This is the data that is more recent relative to the other object.
This boolean flag tells SeqDiff to return the entire comparison, not just the differences between the two features. It will return a hash consisting of the keys:
'old' # the feature from the "old" obj 'new' # the feature from the "new" obj 'comparison' # the complete comparison
This boolean flag will print nice messages about what is going on. Pretty much useless.
See below for more detailed summaries. The main methods are:
Match the two objects' features to each other. ("Line 'em up.")
Return the result of the comparison between the next two matching features from the stream, or nothing if no more. ("Knock 'em down.")
Returns an array of the features that were not matched from the "old" seq object. (i.e. They were 'lost' from older to newer.)
Returns an array of the features that were not matched from the "new" seq object. (i.e. They were 'gained' from older to newer.)
Lance Ferguson <lancer92385@neo.tamu.edu<gt>
Daniel Renfro <bluecurio@gmail.com<gt>
The rest of the documentation details each of the object methods. Internal methods are usually preceeded by an underscore "_".
Title : new Usage : $seqdiff = SeqDiff->new( %options ); Function: Returns a new instance of this class. Returns : An object Args : Named parameters: -old => SeqI object of the older data -new => SeqI object of the newer data -include_all => include all features, not just the comparison -verbose => print (possible) helpful messages
Title : old_seq Usage : $seqdiff->old_seq( $seq ); Function: If a parameter is given to this method it will set the "old" Seq object. This is purely convention (based on what is called "lost" or "gained.") If a parameter is not given, it will return the object that is currently set to the "old" object. Returns : a SeqI implementing object. Args : new value (optional)
Title : new_seq Usage : $seqdiff->new_seq( $seq ); Function: If a parameter is given to this method it will set the "new" Seq object. This is purely convention (based on what is called "lost" or "gained.") If a parameter is not given, it will return the object that is currently set to the "new" object. Returns : a SeqI implementing object. Args : new value (optional)
Title : match_features Usage : $seqdiff->match_features(); Function: First loops through the features and determines which ones are available to match, based on the criteria set forth in SeqDiff::_feature_pair_matches(). These features get grouped into three categories: 1. matched - features that matched 2. lost - features in the "old" object that are not in the "new" 3. gained - features in the "new" object that are not in the "old" Then the method compares each set of matching features using the method SeqDiff::_compare_features(). Returns : null Args : none (Uses member variables.)
Title : get_lost_features Usage : $seqdiff->get_lost_features(); Function: Returns an array of the features that failed to match from the "old" seq object...based on the given criteria. Returns : an array Args : none
Title : get_gained_features Usage : $seqdiff->get_gained_features(); Function: Returns an array of the features that failed to match from the "new" seq object...based on the given criteria. Returns : an array Args : none
Title : next Usage : $seqdiff->next(); Function: Calculates the difference between the next two matching features from the stream and returns it. Returns : A hash of the differences, true if there are no differences, or false if there is nothing else to compare Args : none
Title : primary_tag_whitelist Usage : $seqdiff->primary_tag_whitelist( @list ); Function: Sets or gets the array of whitelisted primary_tags to use for matching the features in _feature_pair_matches. Currently unused. Returns : an array Args : an array or nothing
Title : dbxref_prefix_whitelist Usage : $seqdiff->dbxref_prefix_whitelist( @list ); Function: Sets or gets the array of whitelisted database cross- references to use for matching the features in _feature_pair_matches. Returns : an array Args : an array or nothing
Title : BioPerl_object_handler Usage : $seqdiff->BioPerl_object_handler( %list ); Function: Sets or gets the mapping of object-types to callbacks for specific types of (BioPerl) objects. This method simply registers callbacks for a class. _compare_properties uses this hash to look for code to run when it encounters an object as a property of a feature. See _compare_properties. Example: my %callbacks = ( 'Bio::PrimarySeqI' => \&_my_Bio_PrimarySeqI_hander, 'Bio::LocationI' => \&_my_Bio_LocationI_handler, ); $seqdiff->BioPerl_object_handler( %callbacks ); Returns : a hash Args : an hash or nothing
The methods are listed here for understanding the internals of the package. Most of the time these methods should not be called directly. Use at your own risk.
Title : _feature_pair_matches Usage : $seqdiff->_feature_pair_matches( $fA, $fB ); Function: This method contains the criteria to match features on. It can be overridden to provide specific criteria. Returns : boolean Args : two SeqFeatureI implementing objects, the older one first.
Title : _compare_features Usage : $seqdiff->_compare_features( $feature_A, $feature_B ); Function: Typically run by SeqDiff->match_features() and not called directly, this method will compare two objects. This is the heart of the SeqDiff package. Returns : This method returns one of two things: 1. A reference to a hash; the three keys being 'lost', 'gained', and 'common'. This refers to properties that were either lost, gained, or that both objects have in common. This hash recurses exhaustively. I suggest using Data::Dumper or YAML to have a look at it. 2. False - the two objects are exactly the same and no difference could be found. Args : Two objects in the ambiguous order (old, new);
Title : _compare_properties Usage : $seqdiff->_compare_properties( $fA, $fB ); Function: Compares the internals of the features. Essentially a general object-diffing method. Has code for attaching callbacks for specific types of BioPerl objects (see BioPerl_object_handler.) Returns : boolean Args : two SeqFeatureI implementing objects, the older one first.
Title : _get_differences Usage : $seqdiff->_get_differences(); Function: Returns whatever is currently in the $_differences property. Currently unused. Returns : a hash Args : none
Title : _specific_bp_obj_handler Usage : $seqdiff->_specific_bp_obj_handler( $class, $oA, $oB ); Function: Internal method that looks through the registered callbacks based on the class given. It first looks for any callbacks that match exactly to the classname, then checks inheretance in a depth-first manner. Totally untested! Sounded like a good idea at the time. Returns : ?? Args : string, obj, obj
To install SeqDiff, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SeqDiff
CPAN shell
perl -MCPAN -e shell install SeqDiff
For more information on module installation, please visit the detailed CPAN module installation guide.