--- Sprout.pm 2005/09/09 20:40:41 1.21 +++ Sprout.pm 2005/09/14 13:13:25 1.30 @@ -70,6 +70,8 @@ * B maximum number of residues per sequence, (default C<8000>) +* B suppresses the connection to the database if TRUE, else FALSE + =back For example, the following constructor call specifies a database named I and a user name of @@ -98,6 +100,7 @@ # database connection port maxSegmentLength => 4500, # maximum feature segment length maxSequenceLength => 8000, # maximum contig sequence length + noDBOpen => 0, # 1 to suppress the database open }, $options); # Get the data directory. my $dataDir = $optionTable->{dataDir}; @@ -105,7 +108,11 @@ $optionTable->{userData} =~ m!([^/]*)/(.*)$!; my ($userName, $password) = ($1, $2); # Connect to the database. - my $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName, $password, $optionTable->{port}); + my $dbh; + if (! $optionTable->{noDBOpen}) { + $dbh = DBKernel->new($optionTable->{dbType}, $dbName, $userName, + $password, $optionTable->{port}); + } # Create the ERDB object. my $xmlFileName = "$optionTable->{xmlFileName}"; my $erdb = ERDB->new($dbh, $xmlFileName); @@ -758,13 +765,15 @@ # the start point is the ending. Note that in the latter case we must reverse the DNA string # before putting it in the return value. my ($start, $stop); + Tracer("Parsed location is $beg$dir$len.") if T(SDNA => 4); if ($dir eq "+") { $start = $beg; $stop = $beg + $len - 1; } else { - $start = $beg + $len + 1; + $start = $beg - $len + 1; $stop = $beg; } + Trace("Looking for sequences containing $start through $stop.") if T(SDNA => 4); my $query = $self->Get(['IsMadeUpOf','Sequence'], "IsMadeUpOf(from-link) = ? AND IsMadeUpOf(start-position) + IsMadeUpOf(len) > ? AND " . " IsMadeUpOf(start-position) <= ? ORDER BY IsMadeUpOf(start-position)", @@ -776,18 +785,19 @@ $sequence->Values(['IsMadeUpOf(start-position)', 'Sequence(sequence)', 'IsMadeUpOf(len)']); my $stopPosition = $startPosition + $sequenceLength; + Trace("Sequence is from $startPosition to $stopPosition.") if T(SDNA => 4); # Figure out the start point and length of the relevant section. my $pos1 = ($start < $startPosition ? 0 : $start - $startPosition); - my $len = ($stopPosition <= $stop ? $stopPosition : $stop) - $startPosition - $pos1; + my $len1 = ($stopPosition <= $stop ? $stopPosition : $stop) - $startPosition - $pos1; + Trace("Position is $pos1 for length $len1.") if T(SDNA => 4); # Add the relevant data to the location data. - $locationDNA .= substr($sequenceData, $pos1, $len); + $locationDNA .= substr($sequenceData, $pos1, $len1); } # Add this location's data to the return string. Note that we may need to reverse it. if ($dir eq '+') { $retVal .= $locationDNA; } else { - $locationDNA = join('', reverse split //, $locationDNA); - $retVal .= $locationDNA; + $retVal .= FIG::reverse_comp($locationDNA); } } # Return the result. @@ -1538,6 +1548,7 @@ Trace("Peg 1 is " . $peg1Data->[1] . " and Peg 2 is " . $peg2Data->[1] . ".") if T(Coupling => 4); push @retVal, [$peg1Data->[1], $peg2Data->[1], $peg1Data->[0]]; } + Trace("Last index in evidence result is is $#retVal.") if T(Coupling => 4); } # Return the result. return @retVal; @@ -1587,12 +1598,15 @@ [$retVal], ["ParticipatesInCoupling(from-link)", "Coupling(score)"]); # Check to see if we found anything. if (!@pegs) { + Trace("No coupling found.") if T(Coupling => 4); # No coupling, so undefine the return value. $retVal = undef; } else { # We have a coupling! Get the score and check for inversion. $score = $pegs[0]->[1]; - $inverted = ($pegs[0]->[0] eq $peg1); + my $firstFound = $pegs[0]->[0]; + $inverted = ($firstFound ne $peg1); + Trace("Coupling score is $score. First peg is $firstFound, peg 1 is $peg1.") if T(Coupling => 4); } # Return the result. return ($retVal, $inverted, $score); @@ -1697,13 +1711,13 @@ if ($line =~ m/^>\s*(.+?)(\s|\n)/) { # Here we have a new header. Store the current sequence if we have one. if ($id) { - $retVal{$id} = uc $sequence; + $retVal{$id} = lc $sequence; } # Clear the sequence accumulator and save the new ID. ($id, $sequence) = ("$prefix$1", ""); } else { # Here we have a data line, so we add it to the sequence accumulator. - # First, we get the actual data out. Note that we normalize to upper + # First, we get the actual data out. Note that we normalize to lower # case. $line =~ /^\s*(.*?)(\s|\n)/; $sequence .= $1; @@ -1711,7 +1725,7 @@ } # Flush out the last sequence (if any). if ($sequence) { - $retVal{$id} = uc $sequence; + $retVal{$id} = lc $sequence; } # Close the file. close FASTAFILE; @@ -2037,6 +2051,7 @@ # Get the parameters. my ($self, $entityName, $entityID) = @_; # Check for the entity instance. + Trace("Checking existence of $entityName with ID=$entityID.") if T(4); my $testInstance = $self->GetEntity($entityName, $entityID); # Return an existence indicator. my $retVal = ($testInstance ? 1 : 0);