Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: Why does this happen?

by Transient (Hermit)
on Aug 17, 2005 at 20:34 UTC ( #484582=note: print w/replies, xml ) Need Help??


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

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;

Replies are listed 'Best First'.
Re^4: Why does this happen?
by Marinegirl (Initiate) on Aug 17, 2005 at 20:57 UTC
    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-01-19 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (55 votes). Check out past polls.

    Notices?