Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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.

Replies are listed 'Best First'.
Re^3: error calling variables? Going insane...
by jeffa (Bishop) 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.


    (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

Re^3: error calling variables? Going insane...
by SuicideJunkie (Vicar) 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.


    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 (Monsignor) 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

      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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1091252]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2018-01-17 21:07 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (206 votes). Check out past polls.