cowboyrocks has asked for the wisdom of the Perl Monks concerning the following question:
Input looks like below:-#!/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";} }
My ouput is coming like this(tab separated):-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"
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 :)gene 348634 348822 gene=LOC100129305 gene 348634 348822 gene=LOC100129305 TranscriptID= +XM_001714760.1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Parsing issue
by ig (Vicar) on Mar 19, 2009 at 06:32 UTC | |
by cowboyrocks (Novice) on Mar 19, 2009 at 07:12 UTC | |
|
Re: File Parsing issue
by bichonfrise74 (Vicar) on Mar 19, 2009 at 17:24 UTC | |
by ig (Vicar) on Mar 19, 2009 at 19:51 UTC |