106
my $aln = Bio::SimpleAlign->new(-source => 'meme');
108
my $good_align_sec = 0;
109
my $in_align_sec = 0;
111
while (!$good_align_sec && defined($line = $self->_readline())) {
112
if (!$in_align_sec) {
113
# Check for the meme header
114
if ($line =~ /^\s*MEME\s+version\s+(\S+)/ ){
115
$self->{'meme_vers'} = $1;
105
my $aln = Bio::SimpleAlign->new( -source => 'meme' );
107
my $good_align_sec = 0;
108
my $in_align_sec = 0;
110
while ( !$good_align_sec && defined( $line = $self->_readline() ) ) {
111
if ( !$in_align_sec ) {
113
# Check for the meme header
114
if ( $line =~ /^\s*MEME\s+version\s+(\S+)/ ) {
115
$self->{'meme_vers'} = $1;
116
116
my ($vers) = $self->{'meme_vers'} =~ /^(\d)/;
117
$self->throw($MEME_VERS_ERR) unless ($vers >= 3);
118
$self->{'seen_header'} = 1;
120
# Check if they've output the HTML version
121
if ($line =~ /\<TITLE\>/i){
122
$self->throw($HTML_VERS_ERR);
125
if ($line =~ /MOTIF\s+\d+\s+width.+E-value = (\S+)/) {
126
$self->throw($MEME_NO_HEADER_ERR) unless ($self->{'seen_header'});
129
# Check if we're going into an alignment section
130
if ($line =~ /sites sorted by position/) {
131
$self->throw($MEME_NO_HEADER_ERR) unless ($self->{'seen_header'});
134
} elsif ($line =~ /^(\S+)\s+([+-]?)\s+(\d+)\s+
135
(\S+)\s+([.ACTGNX\-]*)\s+([ACTGNX\-]+)\s+
136
([.ACTGNX\-]*)/xi ) {
137
# Got a sequence line
139
my $strand = ($2 eq '-') ? -1 : 1;
141
my $central = uc($6);
144
# my $left_flank = uc($5);
145
# my $right_flank = uc($7);
147
# Info about the flanking sequence
148
# my $start_len = ($strand > 0) ? length($left_flank) :
149
# length($right_flank);
150
# my $end_len = ($strand > 0) ? length($right_flank) :
151
# length($left_flank);
153
# Make the sequence. Meme gives the start coordinate at the left
154
# hand side of the motif relative to the INPUT sequence.
155
my $end_pos = $start_pos + length($central) - 1;
156
my $seq = Bio::LocatableSeq->new
158
'-display_id' => $seq_name,
159
'-start' => $start_pos,
161
'-strand' => $strand,
162
'-alphabet' => $self->alphabet,
164
# Add the sequence motif to the alignment
166
} elsif (($line =~ /^\-/) || ($line =~ /Sequence name/)){
167
# These are acceptable things to be in the site section
168
} elsif ($line =~ /^\s*$/){
169
# This ends the site section
173
$self->warn("Unrecognized format:\n$line");
177
# Signal an error if we didn't find a header section
178
$self->throw($MEME_NO_HEADER_ERR) unless ($self->{'seen_header'});
180
if ($good_align_sec) {
181
$aln->score($evalue);
118
$self->throw($MEME_VERS_ERR) unless ( $vers >= 3 );
119
$self->{'seen_header'} = 1;
122
# Check if they've output the HTML version
123
if ( $line =~ /\<TITLE\>/i ) {
124
$self->throw($HTML_VERS_ERR);
128
if ( $line =~ /MOTIF\s+\d+\s+width.+E-value = (\S+)/ ) {
129
$self->throw($MEME_NO_HEADER_ERR)
130
unless ( $self->{'seen_header'} );
134
# Check if we're going into an alignment section
135
if ( $line =~ /sites sorted by position/ ) {
136
$self->throw($MEME_NO_HEADER_ERR)
137
unless ( $self->{'seen_header'} );
141
# The first regexp is for version 3, the second is for version 4
142
elsif ( $line =~ /^(\S+)\s+([+-]?)\s+(\d+)\s+
143
\S+\s+[.A-Z\-]*\s+([A-Z\-]+)\s+
146
$line =~ /^(\S+)\s+([+-]?)\s+(\d+)\s+
147
\S+\s+\.\s+([A-Z\-]+)/xi
150
# Got a sequence line
152
my $strand = ( $2 eq '-' ) ? -1 : 1;
154
my $central = uc($4);
157
# my $left_flank = uc($5);
158
# my $right_flank = uc($7);
160
# Info about the flanking sequence
161
# my $start_len = ($strand > 0) ? length($left_flank) :
162
# length($right_flank);
163
# my $end_len = ($strand > 0) ? length($right_flank) :
164
# length($left_flank);
166
# Make the sequence. Meme gives the start coordinate at the left
167
# hand side of the motif relative to the INPUT sequence.
168
my $end_pos = $start_pos + length($central) - 1;
169
my $seq = Bio::LocatableSeq->new(
171
-display_id => $seq_name,
172
-start => $start_pos,
175
-alphabet => $self->alphabet,
178
# Add the sequence motif to the alignment
181
elsif ( ( $line =~ /^\-/ ) || ( $line =~ /Sequence name/ ) ) {
183
# These are acceptable things to be in the site section
185
elsif ( $line =~ /^\s*$/ ) {
187
# This ends the site section
192
$self->warn("Unrecognized format:\n$line");
197
# Signal an error if we didn't find a header section
198
$self->throw($MEME_NO_HEADER_ERR) unless ( $self->{'seen_header'} );
200
if ($good_align_sec) {
201
$aln->score($evalue);