Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Missing \t in print output

by Anonymous Monk
on Jul 15, 2015 at 11:01 UTC ( #1134850=note: print w/replies, xml ) Need Help??


in reply to Missing \t in print output

Hi Sophie.

I don't even understand how your script is able to produce that output. For example:
rattus_norvegicus NA NA NA NA NA NA (etc)... rattus_norvegicus 5 13171176 13038994 -1 132183 NotC +ontiguous_326154Gap (etc)... rattus_norvegicus 5 13004812 12917777 -1 87036 NotCo +ntiguous_253399Gap (etc)...
As far as I can tell, 'rattus norvegicus' at the beginning of a line should come from
@arrayToPrint = (); my @subArray = ($chrInterval,$startInterval,$endInterval,$block,$orde +r,$warning); push(@arrayToPrint,@subArray);
But $chrInterval, $startInterval, $endInterval and $warning don't even change during the 'NORMALBLOCK' loop. Why does the output change then? Am I missing something?

And $chrInterval seems an unlikely name for a variable that contains 'rattus norvegicus'?

Replies are listed 'Best First'.
Re^2: Missing \t in print output
by Sophienz (Acolyte) on Jul 15, 2015 at 11:15 UTC

    Hi,

    Thanks for your question. You are correct, I've cropped the output to only show where the problem appears.

    So the ($chrInterval,$startInterval,$endInterval,$block,$order,$warning) elements don't appear, and they do not change within the NORMALBLOCK loop.

    However, for each iteration of the SP loop, the elements ($newSp,$chr,$start,$end,$strand,$size,$comment) do change. The problem only happens when I print those elements separated by \t.

    The whole line is 251 elements and would be unreadable on here, and won't fit in either apparently and unfortunately the problem only arises when I use a large number of species, ie. a large array.

    Also note that this happened without any join step as well, when I was just printing the elements as they were defined.

    Please let me know if I can make things clearer.

      Hi Sophienz,

      Please let me know if I can make things clearer.

      Post a complete, working test script that shows your problem. Fine if it needs a 251-element array, just make one:
      push @long_list, $_ for (1001..1251);

      Cut out all the code that doesn't affect your problem. Start a new test script with just the loop that is giving you trouble.

      Isolate the problem. Make it happen when you don't have your data in the script. That will prove whether or not the data are to blame.

      The monks don't need to see all your code, but neither do they need to see an arbitrary subsection of it. They do not need your variable names (unless that is the problem) and they do not need your specific data (unless that is the problem). When the problem is programming, your logic, or, Mysteriously Unidentified, the monks need a small, self-contained, working test script that demonstrates the problem.

      The benefit for you is that while you are making the test script, you will usually discover the problem and see how to fix it. And if not, you'll present the monks with something with which they can help you.

      The way forward always starts with a minimal test.
        Thank you for your suggestion, I will make a simple test script that hopefully reproduces the problem. And my apologies for not understanding the correct format, as this is my first post.
      I see. You're saying the example output shows only middle parts of lines. Well...

      Thinking logically, there are four possibilities:

      1. Bug in your program
      2. Bug in your tool that you use to view the output file
      3. Bug in Perl
      4. User error
      So,
      1. I don't see any apparent bugs in the snippet you provided. Although some things are strange, for example, if ($nbGABlocks == 0) {... doesn't seem to have any effect, since @arrayToPrint is emptied before appending more elements anyway (in the NORMALBLOCK loop). Bugs are not impossible, but they must be somewhere else...
      2. How are you viewing the file?
      3. That kind of bug in Perl seems unlikely... What is the Perl version?
      4. Yeah, how are you viewing the file? For example, you're opening the file for appending, are you making sure you're viewing the new part and not the old one?
      There is a number of 'paste your code here' sites on the Internet, e.g. hastebin.com. Would it be possible to paste the output of Data::Dumper and of your program using it or a similar site? And more of your script, too (ideally something that we could actually run).

        I will test it further but I think number 2. (and 4.!) in your list may have been the problem.

        I was viewing the output in two ways, both through the terminal. Either I was printing to STDOUT and looking at the output directly, or printing it to a file (after removing it) and calling the Unix head method on it. Both gave me the missing \t problem.

        I've now tried to copy the file locally and open it with TextWrangler and TextEdit, and that seems to give the required output. Thank you for your suggestion.

        I was using Perl 5.14.

        Come to think of it, there is also a possibility of 'hardware failure'... If all else fails, that might also be worth investigating.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-01-22 01:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?