LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-30-2010, 04:10 AM   #1
nushki
LQ Newbie
 
Registered: Mar 2009
Posts: 26

Rep: Reputation: 0
grep question


Dear all,

could you please help me with grep.
I have pdb files where there is SEQ section like this:
SEQRES 30 A 413 TRP SER PRO VAL GLU MET MET GLY LYS GLN LEU
SEQRES 31 A 413 ARG VAL VAL LEU SER VAL SER SER GLY GLY GLN
SEQRES 32 A 413 VAL LEU LEU VAL LYS ASP LYS GLU
SEQRES 1 B 413 ARG ARG SER PRO PRO ALA ASP ALA ILE PRO LYS
SEQRES 2 B 413 LYS VAL LYS VAL SER HIS ARG SER HIS SER THR
SEQRES 3 B 413 GLY LEU VAL LEU THR LEU GLY GLN GLY ASP VAL
SEQRES 4 B 413 LEU GLY LEU GLY GLU ASN VAL MET GLU ARG LYS
SEQRES 5 B 413 ALA LEU VAL SER ILE PRO GLU ASP VAL VAL GLN
SEQRES 3 C 413 GLY LEU VAL LEU THR LEU GLY GLN GLY ASP VAL
SEQRES 4 C 413 LEU GLY LEU GLY GLU ASN VAL MET GLU ARG LYS
SEQRES 5 C 413 ALA LEU VAL SER ILE PRO GLU ASP VAL VAL GLN

i need to grep only SEQRES section with ID in 3rd column indecated in id_file:
AB

that is i need to grep line with 3rd comuln A and B.


while read file < pdb_file && read id < id_file
do

grep '\<SEQRES' ${file} | grep " ${id} " > ${file}_new

done

it seems that my double read doesn't work. and ${id} can be two or three symbols and i need to separate them because in each line there 3rd column there is only one symbol

any ideas?
 
Old 01-30-2010, 04:19 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
learn to use awk instead
Code:
awk '$1=="SEQRES" && $3 ~/^(A|B)$/' file
 
Old 01-30-2010, 04:19 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
learn to use awk instead
Code:
awk '$1=="SEQRES" && $3 ~/^(A|B)$/' file
 
1 members found this post helpful.
Old 01-30-2010, 04:44 AM   #4
nushki
LQ Newbie
 
Registered: Mar 2009
Posts: 26

Original Poster
Rep: Reputation: 0
that is nice, but i read id_s from id_file and sometimes there is only one symbol and somtimes 2 or 3 or even 4. How to separate symbols in ${id}?

while read file < pdb_file && read id < id_file
do

awk '$1=="SEQRES" && $3 ?? ${id}' ${file}

done

Last edited by nushki; 01-30-2010 at 04:50 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep question torrent478 Linux - Newbie 2 10-08-2008 06:50 PM
question about grep new_2_unix Linux - Newbie 5 12-07-2007 04:45 PM
grep question tokernizer Programming 2 12-20-2005 08:02 AM
grep question vasanthraghavan Programming 3 04-23-2004 12:32 AM
grep question keyops Programming 2 04-09-2004 09:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration