Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
No such thing as a small change
 
PerlMonks  

Perl one liner help

by onlyIDleft (Acolyte)
on Mar 06, 2013 at 10:03 UTC ( #1021983=perlquestion: print w/ replies, xml ) Need Help??
onlyIDleft has asked for the wisdom of the Perl Monks concerning the following question:

Need help to write a Perl one liner for an input file that is slightly different frmo the one descried at the URL: http://bioinf.uni-greifswald.de/bioinf/wiki/pmwiki.php?n=Augustus.UTRTraining

My input file looks as follows:

contig_7643 IMGAG CDS 163 441 . + 0 ID=contig_7643_1.1_cds_1;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 525 617 . + 0 ID=contig_7643_1.1_cds_2;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 807 914 . + 0 ID=contig_7643_1.1_cds_3;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 1589 1703 . + 0 ID=contig_7643_1.1_cds_4;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 1793 1926 . + 2 ID=contig_7643_1.1_cds_5;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 2027 2128 . + 0 ID=contig_7643_1.1_cds_6;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 2214 2306 . + 0 ID=contig_7643_1.1_cds_7;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 2393 2528 . + 0 ID=contig_7643_1.1_cds_8;Parent=contig_7643_1.1

contig_7643 IMGAG CDS 2616 2728 . + 2 ID=contig_7643_1.1_cds_9;Parent=contig_7643_1.1

contig_7643 IMGAG 5'-UTR 67 162 . + 2 ID=contig_7643_1.1_cds_9;Parent=contig_7643_1.1

contig_7643 IMGAG 3'-UTR 2729 3172 . + 2 ID=contig_7643_1.1_cds_9;Parent=contig_7643_1.1

Could someone please help me with a one liner Perl / bash script that reports only those IDs that contain both 5'-UTR and 3'UTR in the input file? Note that what look like spaces between columns in the example input are actually tab separators

Thanks a ton!

Comment on Perl one liner help
Re: Perl one liner help
by Anonymous Monk on Mar 06, 2013 at 10:18 UTC

    Could someone please help me with a one liner ...

    Gee, the page you linked includes a oneliner, it has UTF and everything, presumably all you have to add is 5 or something

Re: Perl one liner help
by Anonymous Monk on Mar 06, 2013 at 10:25 UTC
    Why a one liner? If you don't know how to do it anyway why make it more difficult for people to read your code?
Re: Perl one liner help
by kielstirling (Scribe) on Mar 06, 2013 at 11:03 UTC
    perl -MModern::Perl -ne 'my @l=split /\t/;say $+{ID} if $l[2] =~ /3|5\ +W-UTR/ and $l[8] =~ /ID=(?<ID>.*);/' < input.txt

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2014-04-20 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls