TFBS::Ext

pwmsearch

Summary Package variables Synopsis Description General documentation Methods

Summary
TFBS::Ext::pwmsearch - Perl extension for scanning a DNA sequence object with a position weight matrix
Package variables top
Globals (from use vars definitions)
@EXPORT
%EXPORT_TAGS
@EXPORT_OK
$VERSION
Included modulestop
Bio::SeqIO
File::Temp qw ( :POSIX )
strict
warnings
Synopsistop
  use TFBS::Ext::pwmsearch;
pwmsearch
Descriptiontop
Stub documentation for TFBS::Ext::pwmsearch, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.
None by default.
Methodstop
pwmsearchNo descriptionCode

Methods description


Methods code

pwmsearchdescriptiontopprevnext
sub pwmsearch {
    my ($matrixobj, $seqobj, $threshold, $start, $end) = @_;
    $start = 1 if !defined($start);
    $end = $seqobj->length if !defined($end);
    my $matrixfile = tmpnam();
    open (MATRIX, ">$matrixfile") or die ("Error opening temporary file.");
    print MATRIX $matrixobj->rawprint();
    close MATRIX;

    my $outfile = tmpnam();

    ## pwm_search is confused by long descriptions - we delete desc temporarily:
my $save_desc = $seqobj->desc(); $seqobj->desc(""); my $seqfile; if ($seqobj->{_fastafile}) { $seqfile = $seqobj->{_fastafile}; } else { $seqfile = tmpnam(); my $outstream = Bio::SeqIO->new(-file=>">$seqfile", -format=>"fasta"); $outstream->write_seq(Bio::Seq->new(-seq =>$seqobj->subseq($start, $end), -id =>$seqobj->id)); $outstream->close(); } $seqobj->desc($save_desc); ## calculate threshold
if ($threshold) { if ($threshold =~ /(.+)%/) { ## percentage
$threshold = $matrixobj->{min_score} + ($matrixobj->{max_score} - $matrixobj->{min_score})* $1/100;
} else { ## absolute value
## $threshold = $args{-threshold};
} } else { ## no threshold given
$threshold = $matrixobj->{min_score} -1; } search_xs($matrixfile, $seqfile, $threshold, $matrixobj->name()."", $matrixobj->{'class'}."", $outfile); unlink $seqfile unless $seqobj->{'_fastafile'}; unlink $matrixfile; my $hitlist = TFBS::SiteSet->new(); my ($TFname, $TFclass) = ($matrixobj->{name}, $matrixobj->{class}); my $save_delim = $/; ## bugfix submitted
local $/ = "\n"; ## by Michal Lapidot
open (OUTFILE, $outfile) or die("Could not read temporary outfile"); while (my $line = <OUTFILE>) { ## print STDERR $line;
chomp $line; $line =~ s/^\s+//; $line =~ s/ *\t */\t/g; my ($seq_id, $factor, $class, $strand, $score, $pos, $siteseq) = (split /\t/, $line)[0, 2, 3, 4, 5, 7, 9]; my $num_strand = ($strand eq "-")? "-1" : "1"; my $site = TFBS::Site->new ( -seq_id => $seqobj->display_id()."", -seqobj => $seqobj, -strand => $num_strand."", -pattern => $matrixobj, -siteseq => $siteseq."", -score => $score."", -start => $pos +$start -1, -end => $pos +$start +length($siteseq) -2 ); $hitlist->add_site($site); } close OUTFILE; $/ = $save_delim; unlink $outfile; return $hitlist;
}

General documentation

AUTHOR top
A. U. Thor, a.u.thor@a.galaxy.far.far.away
SEE ALSO top
perl(1).