[Bio] / Sprout / SimBlocks.pm Repository:
ViewVC logotype

Diff of /Sprout/SimBlocks.pm

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

revision 1.4, Wed Jan 11 19:39:20 2006 UTC revision 1.7, Mon Feb 13 15:42:48 2006 UTC
# Line 213  Line 213 
213      my ($class, $dbname, $dbType, $port) = @_;      my ($class, $dbname, $dbType, $port) = @_;
214      # Plug in the default values.      # Plug in the default values.
215      if (! $dbname) {      if (! $dbname) {
216          $dbname = $FIG_Config::simBlocksDB;          $dbname = DBName();
217      }      }
218      if (! $dbType) {      if (! $dbType) {
219          $dbType = $FIG_Config::dbms;          $dbType = $FIG_Config::dbms;
# Line 231  Line 231 
231      return $retVal;      return $retVal;
232  }  }
233    
234    =head3 DBName
235    
236    C<< my $name = SimBlocks::DBName; >>
237    
238    Return the name of the database. This is set from a config variable, but if the
239    variable is undefined a default value is used.
240    
241    =cut
242    
243    sub DBName {
244        my $retVal;
245        if (defined $FIG_Config::simBlocksDB) {
246            $retVal = $FIG_Config::simBlocksDB;
247        } else {
248            $retVal = "Blocks";
249        }
250        return $retVal;
251    }
252    
253  =head3 DefaultDistances  =head3 DefaultDistances
254    
255  C<< my $distances = DefaultDistances(); >>  C<< my $distances = DefaultDistances(); >>
# Line 825  Line 844 
844      return @retVal;      return @retVal;
845  }  }
846    
   
   
847  =head3 MergeDNA  =head3 MergeDNA
848    
849  C<< my ($groupSequence, $variance) = SimBlocks::MergeDNA($groupSequence, $newSequence); >>  C<< my ($groupSequence, $variance) = SimBlocks::MergeDNA($groupSequence, $newSequence); >>
# Line 1182  Line 1199 
1199      my $loc = BasicLocation->new($location);      my $loc = BasicLocation->new($location);
1200      # Determine the parameters needed to get the desired list of regions.      # Determine the parameters needed to get the desired list of regions.
1201      my ($left, $right, $contigID) = ($loc->Left, $loc->Right, $loc->Contig);      my ($left, $right, $contigID) = ($loc->Left, $loc->Right, $loc->Contig);
1202        Trace("Searching for regions near " . $loc->String) if T(4);
1203      # Ask for the regions in the section we want.      # Ask for the regions in the section we want.
1204      my @regions = $self->GetAll(['Region', 'IncludesRegion', 'GroupBlock'],      my @regions = $self->GetAll(['Region', 'IncludesRegion', 'GroupBlock'],
1205                                  'Region(end) >= ? AND Region(position) <= ? AND Region(contigID) = ?',                                  'Region(endpoint) >= ? AND Region(position) <= ? AND Region(contigID) = ?',
1206                                  [$left, $right, $contigID],                                  [$left, $right, $contigID],
1207                                  ['GroupBlock(id)', 'GroupBlock(pattern)',                                  ['GroupBlock(id)', 'GroupBlock(pattern)',
1208                                   'GroupBlock(len)',                                   'GroupBlock(len)',
1209                                   'Region(position)', 'Region(end)',                                   'Region(position)', 'Region(endpoint)',
1210                                   'Region(content)']);                                   'Region(content)']);
1211      # Loop through the regions found. For each region we will output a location string.      # Loop through the regions found. For each region we will output a location string.
1212      for my $regionData (@regions) {      for my $regionData (@regions) {
# Line 1299  Line 1317 
1317              # Get the length of the contig in question.              # Get the length of the contig in question.
1318              my $len = $fig->contig_ln($genomeID, $locObject->Contig);              my $len = $fig->contig_ln($genomeID, $locObject->Contig);
1319              # Expand the location.              # Expand the location.
1320              $locObject->Widen($distance);              $locObject->Widen($distance, $len);
1321                # Insure the location is Sprout-style;
1322                $locObject->FixContig($genomeID);
1323              # Get the desired block pieces.              # Get the desired block pieces.
1324              my @pieces = $self->GetBlockPieces($locObject);              my @pieces = $self->GetBlockPieces($locObject);
1325                Trace(scalar(@pieces) . " pieces found for location $loc.") if T(4);
1326              # Put them in the hash.              # Put them in the hash.
1327              for my $piece (@pieces) {              for my $piece (@pieces) {
1328                  $retHash{$piece} = 1;                  $retHash{$piece} = 1;
# Line 1314  Line 1335 
1335      my @retVal = ();      my @retVal = ();
1336      for my $piece (keys %retHash) {      for my $piece (keys %retHash) {
1337          my $loc = BasicLocation->new($piece);          my $loc = BasicLocation->new($piece);
1338          push @retVal, $piece;          push @retVal, $loc;
1339      }      }
1340        Trace("Beginning sort.") if T(3);
1341      @retVal = sort { BasicLocation::Cmp($a,$b) } @retVal;      @retVal = sort { BasicLocation::Cmp($a,$b) } @retVal;
1342        Trace(scalar(@retVal) . " pieces found before overlap check.") if T(3);
1343      # Now the locations are sorted by block ID, start position, and descending      # Now the locations are sorted by block ID, start position, and descending
1344      # length. This means that if there's an overlap, the two overlapping      # length. This means that if there's an overlap, the two overlapping
1345      # pieces will be next to each other.      # pieces will be next to each other.

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3