Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: Why does this happen?

by poj (Abbot)
on Aug 17, 2005 at 20:17 UTC ( #484577=note: print w/replies, xml ) Need Help??

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; } }

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://484577]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-01-16 19:45 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (49 votes). Check out past polls.