Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: error calling variables? Going insane...

by lecb (Acolyte)
on Jun 25, 2014 at 21:14 UTC ( #1091252=note: print w/ replies, xml ) Need Help??


in reply to Re: error calling variables? Going insane...
in thread error calling variables? Going insane...

I'm sorry you feel that my question was inappropriate. I'm not too sure how I can ask the question without context though? I don't understand how $seq is not meeting the if condition when everything else is.


Comment on Re^2: error calling variables? Going insane...
Download Code
Re^3: error calling variables? Going insane...
by SuicideJunkie (Priest) on Jun 25, 2014 at 21:46 UTC

    Since this is a question regarding why your if condition is unexpectedly true, collect some sample cases where it is not behaving as expected.

    Since you are doing a simple regex test against a single value, your question likely boils down to "Why does this string get matched by this regex?"

    if ($strands{$ID[$i]} =~ m/\+/) { That regex matches any string containing a '+' anywhere in it. In the case where you think it should NOT match but is matching, print out the string $strands{$ID[$i]} (not just $ID[$i] as your comment implies) and see what it contains.


    Appended:

    I notice at the top you are checking if '-', elsif '+', but at the bottom of your code, you are checking if '+' elsif '-'. If you have a string that contains both a + and a -, that may be causing some confusion.

      Thank you for taking the time to have a look; I have only been learning for 2 weeks. My %strands is as follows:

      $key = some ID $value = + or -
      If I print out $strands{$ID[$i]}, all it does is print a string of pluses and minuses.

      I have however figured out the problem:
      my @ID; foreach my $line(@col_NM) { if ($line =~ m/(NM\_\d+)/) { push (@ID, $1); } }
      If $line did not match /(NM\_\d+)/, it would not be added to @ID . Since, I iterate through $ID[$i], I became out of sync with my positives and minuses.

      Thank you for pointing me in the right direction and your patience! :) El

Re^3: error calling variables? Going insane...
by poj (Priest) on Jun 25, 2014 at 21:58 UTC
    Forgive me if this is nonsense but if all your output is going to INTRONS_three then presumably the length of $seq is not 9. So does that mean that this block is not entered ?
    if ($intron_from_boundary[$i] >= -6) { $left_of_boundary = 3; #$right_of_boundary = 6; $left_of_boundary = $left_of_boundary - intron_from_bound +ary[$i]; $new_left = 51 - $left_of_boundary; $seq = substr( $col7[$i], $new_left, 9); $matchID = $ID[$i] . "\t" . $intron_from_boundary[$i] +. "\t" . "on the negative strand"; }
    Is which case is this $intron_from_boundary[$i] >= -6 the correct test, any number greater or equal to -6 ie. -5, -4, -3 etc or should it be less or equal to -6 ie -7,-8,9 etc
    poj

      Dear Poj,
      I have another subroutine that I call later that pulls out a sequence of length = 9, and this works absolutely fine. I have replied to suicidejunkie and have worked out the errors of my ways! - El

Re^3: error calling variables? Going insane...
by jeffa (Chancellor) on Jun 25, 2014 at 22:02 UTC

    "I'm sorry you feel that my question was inappropriate."

    What precisely is your question? A long time ago Ovid wrote this reply: Clean your room. If you take the time to make your question easy to read, then others will give the time to help you find the solution.

    For starters, please consider formatting your code with Perl Tidy as your indention is extremely inconsistent and makes your code extremely hard to read.


    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    

      Dear Jeffa,
      Thanks for taking the time to reply. I am very much a beginner, and still learning the ropes. I am not very au fait with the "tidy" etiquette of perl yet. I will have a look at Perl Tidy and make sure I improve my scripting technique.
      Many thanks, E

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-09-21 05:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls