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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Here's exactly what I used to test your code and data:

#!/usr/bin/env perl use strict; use warnings; use feature qw(say); #my $file = "BSAC.pl"; my %cod = ( 1 => "red", 2 => "non", 3 => "green" ); #open my $in, "<", "$file"; #open my $out, ">", "output.txt"; say "Coordinate No of Strains AA Change"; my $SNP; my $count; my $change; while ( my $line = <DATA> ) { chomp $line; #say qq(DEBUG: Line = "$line"); if ( $line =~ /^FT\s+SNP\s+(\d+)/ ){ $SNP = $1; #say qq(\$SNP = $1;); } elsif ( $line =~ /^FT\s+\/note="(.*)"/) { my $note = $1; #say qq(my \$note = $1); $count = ($note =~ tr/=/=/); $note =~ /\((AA \w+->\w+)\)\s*$/; $change = $1 || ""; } elsif ( $line =~ /^FT\s+\/colour=(\d+)/ ) { #say qq(Code = $1); if ( $cod{$1} eq "non" ) { printf "%-12.12s %-15.15s %s\n", $SNP, $count, $change; } } } __DATA__ ID SNP FT SNP 433 FT /note="refAllele: T SNPstrains: 7083_1#5=C 7414_8#8=C 7480_8#4 +9=C " FT /colour=1 FT SNP 442 FT /note="refAllele: T SNPstrains: 7065_8#2=C 7065_8#94=C 7083_1# +2=C 7083_1#3=C 7083_1#41=C 7083_1#42=C 7083_1#43=C " FT /colour=1 FT SNP 460 FT /note="refAllele: T SNPstrains: 7564_8#14=C " FT /colour=1 FT SNP 703 FT /note="refAllele: G SNPstrains: 7521_5#39=A (non-synonymous) ( +AA Ala->Thr) " FT /colour=2 FT SNP 937 FT /note="refAllele: G SNPstrains: 7414_8#30=T (non-synonymous) ( +AA Val->Leu) " FT /colour=2 FT SNP 1269 FT /note="refAllele: G SNPstrains: 7480_7#22=A (synonymous) 7480_ +7#62=A (synonymous) " FT /colour=3 FT SNP 1804 FT /note="refAllele: T SNPstrains: 7414_7#66=A (non-synonymous) ( +AA Ser->Thr) 7414_8#44=A (non-synonymous) (AA Ser->Thr) 7521_6#54=A ( +non-synonymous) (AA Ser->Thr) " FT /colour=2

Try running this. Assuming it works, try changing the data to something you know will generate the warnings - keeping the data to an absolute minimum.

If you are also unable to reproduce the warnings, then the problem may lie in your input file. There might be embedded characters that aren't showing up when the text is copied and pasted. Anyway, I'm jumping the gun a bit here - see how you go with above code first.

-- Ken


In reply to Re^3: Parsing problem by kcott
in thread Parsing problem by MB123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (9)
    As of 2014-12-29 09:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (185 votes), past polls