[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.73, Sun Jun 25 02:44:43 2006 UTC revision 1.75, Sun Jun 25 18:02:35 2006 UTC
# Line 1825  Line 1825 
1825      return ($retVal, $inverted, $score);      return ($retVal, $inverted, $score);
1826  }  }
1827    
1828    =head3 GetSynonymGroup
1829    
1830    C<< my $id = $sprout->GetSynonymGroup($fid); >>
1831    
1832    Return the synonym group name for the specified feature.
1833    
1834    =over 4
1835    
1836    =item fid
1837    
1838    ID of the feature whose synonym group is desired.
1839    
1840    =item RETURN
1841    
1842    The name of the synonym group to which the feature belongs. If the feature does
1843    not belong to a synonym group, the feature ID itself is returned.
1844    
1845    =back
1846    
1847    =cut
1848    
1849    sub GetSynonymGroup {
1850        # Get the parameters.
1851        my ($self, $fid) = @_;
1852        # Declare the return variable.
1853        my $retVal;
1854        # Find the synonym group.
1855        my @groups = $self->GetFlat(['IsSynonymGroupFor'], "IsSynonymGroupFor(to-link) = ?",
1856                                       [$fid], 'IsSynonymGroupFor(from-link)');
1857        # Check to see if we found anything.
1858        if (@groups) {
1859            $retVal = $groups[0];
1860        } else {
1861            $retVal = $fid;
1862        }
1863        # Return the result.
1864        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.73  
changed lines
  Added in v.1.75

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3