sub parse_results
{ my ($self) = @_;
my $filehandle;
my $resfile = $self->resultsfile();
my @fps;
if (-e $resfile) {
if (-z $resfile) {
print STDERR "Prints didn't find any hits\n";
return;
} else {
open (CPGOUT, "<$resfile") or $self->throw("Error opening ", $resfile, "\n "); }
}
my $id;
my $line;
my $sequenceId;
my @features;
my %evalue;
my %printsac;
while (<CPGOUT>) {
$line = $_;
print STDERR "Next line: $line";
chomp $line;
if ($line =~ s/^Sn;//) {
($sequenceId) = $line =~ /^\s*(\w+)/;
}
if ($line =~ s/^1TBH//) {
my ($id) = $line =~ /^\s*(\w+)/;
my ($ac) = $line =~ /(PR\w+)[;\.]*\s*$/;
$printsac{$id} = $ac;
print STDERR "1TBH line = $line\n";
print STDERR "In 1TBH data, printsac{$id} = $ac\n";
}
if ($line =~ /^2TBH/) {
print STDERR "got a 2TBH line: $line\n";
my @line = split /\s+/, $line;
$evalue{$line[1]} = $line[9];
print STDERR "hash evalue of $line[1] = $line[9]\n";
}
if ($line =~ s/^3TB//) {
if ($line =~ s/^[HN]//) {
my ($num,$temp1,$tot1) = "";
$line =~ s/^\s+//;
print STDERR "line = $line\n";
my @elements = split /\s+/, $line;
my ($fingerprintName,$motifNumber,$temp,$tot,$percentageIdentity,$profileScore,$pvalue,$subsequence,$motifLength,$lowestMotifPosition,$matchPosition,$highestMotifPosition) = @elements;
print STDERR "fingerprintName=$fingerprintName\n";
my $start = $matchPosition;
my $hash_substring;
my $end;
if($subsequence =~ /(\#+)$/){
$hash_substring = $1;
$end = $matchPosition + $motifLength - 1 - length($hash_substring);
} else {
$end = $matchPosition + $motifLength - 1;
}
if (! exists $printsac{$fingerprintName}) {next;}
my $print = $printsac{$fingerprintName};
my $feat = "$print,$start,$end,$percentageIdentity,$profileScore,$evalue{$fingerprintName}";
print STDERR "features= $feat\n";
print "matched\n";
my $hstart = 0;
my $hend = 0;
my $evalue = $evalue{$fingerprintName};
print STDERR "writing to database\n";
my $fp= $self->create_protein_feature($start, $end, $profileScore, $sequenceId, $hstart, $hend, $print, $self->analysis, $evalue, $percentageIdentity);
push @fps, $fp;
}
}
}
close (CPGOUT);
$self->output(\@fps);
}
1; } |