http://qs321.pair.com?node_id=484577


in reply to Re: Why does this happen?
in thread Why does this happen?

Because $qbase is a letter, $query_sequence[$qbase] is not valid. To fix it change to this
foreach $qbase ($q_start .. $q_end) # qbase is now a number { if ( ($query_sequence[$qbase] =~ /[nN]/) && ($subj_sequence[$qbase] +!~ /[nN]/) ) { ++$ncount; } }
poj

Replies are listed 'Best First'.
Re^3: Why does this happen?
by Transient (Hermit) on Aug 17, 2005 at 20:34 UTC
    I'd keep them separate in case ($#qbase != $#sbase), and since you're not doing anything else with the index, just loop through them all...
    foreach $qbase ( @qbase ) { if ( uc($qbase) eq 'N' ) { ++$ncount; } } foreach $sbase ( @sbase ) { if ( uc($sbase) eq 'N' ) { ++$ncount; } }
    or more concisely...
    do { $ncount++ if /n/i } foreach ( @qbase, @sbase );
    Update: disregard, read the OP wrong

    Update: re-read, and the answer doesn't take into account if subj_sequence is n and query is not...
    foreach my $idx ( 1..$#query_sequence ) { if ( $query_sequence[$idx] =~ /n/i && $subj_sequence[$idx] !~ /n/i ) + { $ncount++; } elsif ( $subj_sequence[$idx] =~ /n/i && $query_sequence[$idx] !~ / +n/i ) { $ncount++; } }
    (Note that it is assumed that $#query_sequence = $#subj_sequence)

    Update: again..
    $ncount = grep { ($qbase[$_] =~ /n/i && $sbase[$_] !~ /n/i) || ($qbase +[$_] !~ /n/i && $sbase[$_] =~ /n/i) } 1..$#qbase;
      Wow .... I never thought I'd get this much help this fast. Thankyou both very much.

      "(Note that it is assumed that $#query_sequence = $#subj_sequence)"
      The problem is that they aren't equal - it's a bioinformaticological alignment problem - so I have 2 sequences, each with an alignment start and end position, which aren't necessarily at the start and end of the sequence.

      Poj's thing seems to work - thankyou.

      Marinegirl x