Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Perl one liner help

by onlyIDleft (Scribe)
on Mar 06, 2013 at 10:03 UTC ( [id://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!

Replies are listed 'Best First'.
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
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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-19 17:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found