Hi Monks,
I am trying to parse a large file and filter according the fields I require.
My code looks like this:-
#!/usr/bin/perl $fn = $ARGV[0]; open(FH, "$fn") || die("cannot open:$!"); $\ = ' '; while(<FH>) { $\ = "\n" if eof; chomp($_); $_ =~ s/\(|\)//xmg; if($_ =~ /LOCUS\s+(\S+)/) { $gi=$1; } elsif($_ =~ /\A\s+(\w+)\s+(\S+)\.\.(\S+)/) { print "\t\t$gi +\t$1\t$2\t$3\n"; } elsif($_ =~ /gene\=\"(\S+)\"/) { print "\t\t$gi\t\t\t\t\tge +ne=$1\n"; } elsif($_ =~ /\/transcript_id\=\"(\S+)\"/) {print "\t\t$gi\t +\t\t\t\tTranscriptID=$1\n";} }
Input looks like below:-
gene 348634..348822 /gene="LOC100129305" /note="Derived by automated computational analysi +s using gene prediction method: GNOMON. Supporting eviden +ce includes similarity to: 1 Protein" /db_xref="GeneID:100129305" mRNA 348634..348822 /gene="LOC100129305" /product="similar to C21orf94 protein" /note="Derived by automated computational analysi +s using gene prediction method: GNOMON. Supporting eviden +ce includes similarity to: 1 Protein" /transcript_id="XM_001714760.1" /db_xref="GI:169215265" /db_xref="GeneID:100129305"
My ouput is coming like this(tab separated):-
gene 348634 348822 gene=LOC100129305 gene 348634 348822 gene=LOC100129305 TranscriptID=XM_001714760.1
Whereas I want it to come like like:-
gene 348634 348822 gene=LOC100129305 gene 348634 348822 gene=LOC100129305 TranscriptID= +XM_001714760.1
Thanks in advance
cowboy :)

In reply to File Parsing issue by cowboyrocks

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.