[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.74, Sun Jun 25 07:34:46 2006 UTC revision 1.75, Sun Jun 25 18:02:35 2006 UTC
# Line 1864  Line 1864 
1864      return $retVal;      return $retVal;
1865  }  }
1866    
1867    =head3 GetBoundaries
1868    
1869    C<< my ($contig, $beg, $end) = $sprout->GetBoundaries(@locList); >>
1870    
1871    Determine the begin and end boundaries for the locations in a list. All of the
1872    locations must belong to the same contig and have mostly the same direction in
1873    order for this method to produce a meaningful result. The resulting
1874    begin/end pair will contain all of the bases in any of the locations.
1875    
1876    =over 4
1877    
1878    =item locList
1879    
1880    List of locations to process.
1881    
1882    =item RETURN
1883    
1884    Returns a 3-tuple consisting of the contig ID, the beginning boundary,
1885    and the ending boundary. The beginning boundary will be left of the
1886    end for mostly-forward locations and right of the end for mostly-backward
1887    locations.
1888    
1889    =back
1890    
1891    =cut
1892    
1893    sub GetBoundaries {
1894        # Get the parameters.
1895        my ($self, @locList) = @_;
1896        # Set up the counters used to determine the most popular direction.
1897        my %counts = ( '+' => 0, '-' => 0 );
1898        # Get the last location and parse it.
1899        my $locObject = BasicLocation->new(pop @locList);
1900        # Prime the loop with its data.
1901        my ($contig, $beg, $end) = ($locObject->Contig, $locObject->Left, $locObject->Right);
1902        # Count its direction.
1903        $counts{$locObject->Dir}++;
1904        # Loop through the remaining locations. Note that in most situations, this loop
1905        # will not iterate at all, because most of the time we will be dealing with a
1906        # singleton list.
1907        for my $loc (@locList) {
1908            # Create a location object.
1909            my $locObject = BasicLocation->new($loc);
1910            # Count the direction.
1911            $counts{$locObject->Dir}++;
1912            # Get the left end and the right end.
1913            my $left = $locObject->Left;
1914            my $right = $locObject->Right;
1915            # Merge them into the return variables.
1916            if ($left < $beg) {
1917                $beg = $left;
1918            }
1919            if ($right > $end) {
1920                $end = $right;
1921            }
1922        }
1923        # If the most common direction is reverse, flip the begin and end markers.
1924        if ($counts{'-'} > $counts{'+'}) {
1925            ($beg, $end) = ($end, $beg);
1926        }
1927        # Return the result.
1928        return ($contig, $beg, $end);
1929    }
1930    
1931  =head3 CouplingID  =head3 CouplingID
1932    
1933  C<< my $couplingID = $sprout->CouplingID($peg1, $peg2); >>  C<< my $couplingID = $sprout->CouplingID($peg1, $peg2); >>

Legend:
Removed from v.1.74  
changed lines
  Added in v.1.75

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3