Fedora Linux Support Community & Resources Center
  #1  
Old 28th May 2012, 07:03 AM
papori Offline
Registered User
 
Join Date: Nov 2010
Posts: 58
linuxfedorafirefox
How to select only the line that after pattern?

Hi all,
Assuming i have this text:
@HISEQ1:1360NU8ACXX:5:1101:4153:1981 1:N:0:ACTTGA
ATTGCAATACTAACTGTGACTCAACTGAGGAGTTAAGATGTANNNNNNNN
+
CCCFFFFFHHHHHJJJJJJJJJJIJIA<CCC2111:EGH?1?:?DHHIGI
@HISEQ1:1360NU8ACXX:5:1101:4876:1982 1:N:0:ACTTGA
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
+
CCCFFFFFHHHHHIJJJJJJJJ@<1??GHII:002?DHGGHFHIIIIHHI
@HISEQ1:1360NU8ACXX:5:1101:4876:1982 1:N:0:ACTTGA
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
+
CCCFFFFFHHHHHIJJJJJJJJ@<1??GHII:002?DHGGHFHIIIIHHI
@HISEQ1:1360NU8ACXX:5:1101:4876:1982 1:N:0:ACTTGA
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
+
CCCFFFFFHHHHHIJJJJJJJJ@<1??GHII:002?DHGGHFHIIIIHHI

i want to select only the first line after "@HISEQ" in all the file.
in this example the output should be :
ATTGCAATACTAACTGTGACTCAACTGAGGAGTTAAGATGTANNNNNNNN
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT

How can i do this?
I found grep -A1, but it select also the @HISEQ line...

Thanks,
Pap
Reply With Quote
  #2  
Old 28th May 2012, 07:17 AM
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,716
linuxfirefox
Re: How to select only the line that after pattern?

awk '/@HISEQ/{getline;print}' < filename

Hope you aren't creating an evil clone with those RNA base sequences.
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe

Last edited by stevea; 28th May 2012 at 07:21 AM.
Reply With Quote
  #3  
Old 28th May 2012, 07:28 AM
papori Offline
Registered User
 
Join Date: Nov 2010
Posts: 58
linuxfedorafirefox
Re: How to select only the line that after pattern?

Thanks, really help
Reply With Quote
  #4  
Old 28th May 2012, 08:05 AM
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,716
linuxfirefox
Re: How to select only the line that after pattern?

Just for fun - demonstrates bash associative arrays.

'rnadecode' script

Code:
#!/bin/bash
# rnadecode - reads strings on stdin

declare -A rna
	
rna=(
	["TTT"]="Phe" ["TTC"]="Phe" ["TTA"]="Leu" ["TTG"]="Leu" 
	["TCT"]="Ser" ["TCC"]="Ser" ["TCA"]="Ser" ["TCG"]="Ser" 
	["TAT"]="Tyr" ["TAC"]="Tyr" ["TAA"]="StopOchre" ["TAG"]="StopAmber" 
	["TGT"]="Cys" ["TGC"]="Cys" ["TGA"]="StopOpal" ["TGG"]="Trp" 
 
	["CTT"]="Leu" ["CTC"]="Leu" ["CTA"]="Leu" ["CTG"]="Leu" 
	["CCT"]="Pro" ["CCC"]="Pro" ["CCA"]="Pro" ["CCG"]="Pro" 
	["CAT"]="His" ["CAC"]="His" ["CAA"]="Gln" ["CAG"]="Gln" 
	["CGT"]="Arg" ["CGC"]="Arg" ["CGA"]="Arg" ["CGG"]="Arg" 
 
	["ATT"]="Ile" ["ATC"]="Ile" ["ATA"]="Ile" ["ATG"]="Met" 
	["ACT"]="Thr" ["ACC"]="Thr" ["ACA"]="Thr" ["ACG"]="Thr" 
	["AAT"]="Asn" ["AAC"]="Asn" ["AAA"]="Lys" ["AAG"]="Lys" 
	["AGT"]="Ser" ["AGC"]="Ser" ["AGA"]="Arg" ["AGG"]="Arg" 
 
	["GTT"]="Val" ["GTC"]="Val" ["GTA"]="Val" ["GTG"]="Val" 
	["GCT"]="Ala" ["GCC"]="Ala" ["GCA"]="Ala" ["GCG"]="Ala" 
	["GAT"]="Asp" ["GAC"]="Asp" ["GAA"]="Glu" ["GAG"]="Glu" 
	["GGT"]="Gly" ["GGC"]="Gly" ["GGA"]="Gly" ["GGG"]="Gly" 
)

while read LINE
do
    SEQ=$(echo $LINE| cut -dN -f1)
    AA=""
    for((p=0 ; p<${#SEQ}-2 ; p+=3))
    do
	AA+="${rna[${SEQ:$p:3}]}."
    done
    echo $AA
done

Code:
[stevea@crucibulum tmp]$ awk '/@HISEQ/{getline;print}' < filename
ATTGCAATACTAACTGTGACTCAACTGAGGAGTTAAGATGTANNNNNNNN
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
ATCATCCTTCTTCATTTCTGGGGGTTTGTCTGGTTTCAGAGGAGCTGCTT
[stevea@crucibulum tmp]$ awk '/@HISEQ/{getline;print}' < filename | ./rnadecode 
Ile.Ala.Ile.Leu.Thr.Val.Thr.Gln.Leu.Arg.Ser.StopOchre.Asp.Val.
Ile.Ile.Leu.Leu.His.Phe.Trp.Gly.Phe.Val.Trp.Phe.Gln.Arg.Ser.Cys.
Ile.Ile.Leu.Leu.His.Phe.Trp.Gly.Phe.Val.Trp.Phe.Gln.Arg.Ser.Cys.
Ile.Ile.Leu.Leu.His.Phe.Trp.Gly.Phe.Val.Trp.Phe.Gln.Arg.Ser.Cys.
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe
Reply With Quote
  #5  
Old 3rd June 2012, 07:55 AM
papori Offline
Registered User
 
Join Date: Nov 2010
Posts: 58
linuxfedorafirefox
Re: How to select only the line that after pattern?

Thanks! The aa script is nice..

I have another question..
I have file that looks like this:

>k26_9 50 75
ATGGGTTTTGACACGGAATGAGATCCAACTGGCAGACGATTATAAATCCG
>k26_17 51 80
GTAATGGGAAGATGCAAAGGTTTGAGATGTAATTTTATGGGTTGAGTTGG T
>k26_18 55 152
AGCGGTTCGGTAACATTTGTTCGGACAAGTAAGCTCCTTCAACCGTGTCA TCTCC

the lines that have ">k..." is the headers for the line that comes after ATG... (sequence)

How can i select the header & the sequence where the second column (numbers-50,51,55) in the header is higher than 53.

in this example i want only the third pair:
>k26_18 55 152
AGCGGTTCGGTAACATTTGTTCGGACAAGTAAGCTCCTTCAACCGTGTCA TCTCC

Thanks!
Reply With Quote
Reply

Tags
line, pattern, select

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl pattern matching ibbo Programming & Packaging 0 30th April 2009 11:03 AM
Pattern Matching petervoldon Using Fedora 3 17th October 2008 10:19 AM
target pattern contains no `%' (firefox) CopyrightPhilly Using Fedora 1 8th April 2008 07:17 AM
Matching the '\' pattern in PHP preg_replace() CD-RW Programming & Packaging 3 18th July 2007 12:01 AM


Current GMT-time: 19:16 (Wednesday, 30-07-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat