To parse through the file and print output using awk or sed script

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2007
Posts: 3
Reputation: cdfd1982 is an unknown quantity at this point 
Solved Threads: 0
cdfd1982 cdfd1982 is offline Offline
Newbie Poster

To parse through the file and print output using awk or sed script

 
0
  #1
Feb 29th, 2008
A file is

ELLPSYSTATL
ELLSUYSTLTL
* * * : . * * * :* *
HHULJKLOPOA
HPULJKLPOOA
* . * * * * * : : * *
and it is a long file .....



so output shud be
where there is : and . counting start from E and end upto A.

P4S
S5U
A9L
H13P
O19P
P20O
Last edited by cdfd1982; Feb 29th, 2008 at 2:20 pm. Reason: change in input format
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: To parse through the file and print output using awk or sed script

 
0
  #2
Mar 1st, 2008
Hey There,

Not sure what you're looking for based on the output and then the results.

Are these colons and dots in the text? And, the case of P4S, what context are you using to count from E to A?

If you could clarify, that would be great. I'm not really sure what you're trying to accomplish.

Thanks,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 3
Reputation: cdfd1982 is an unknown quantity at this point 
Solved Threads: 0
cdfd1982 cdfd1982 is offline Offline
Newbie Poster

Re: To parse through the file and print output using awk or sed script

 
0
  #3
Mar 1st, 2008
Thanx ...
See this simple file
ABCDEFG
ABCEEFH
* * * : * * * .
so it have three rows . Those first two rows say
A and A match then it will be * (asterisk) in the third row.
and those D and E not match there will be colon (: ) or
G and H not match .(fullstop) in the third row

Our question is
In third row where there is colon (: ) and .(fullstop)
tell the number and wht is that name at that number
therefore output will be
D4E because colon is at 4 number
G7H because fullstop is at 7 number

And it will be a long file where there is colon and full stop
just tell the number and name ...

One more question is
In some other files colon or fullstop may be at 4th row or 5th row
can u script this one also separately
Last edited by cdfd1982; Mar 1st, 2008 at 8:10 am. Reason: changes in input format
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: To parse through the file and print output using awk or sed script

 
0
  #4
Mar 2nd, 2008
Hey There,

Are there always only 2 mismatched letters in each pair of rows? Just wondering if you do multiple colons before full stop and how you handle that.

Also, can you post what you have so far? Just curious as to where you're having the issue.

Thanks

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 3
Reputation: cdfd1982 is an unknown quantity at this point 
Solved Threads: 0
cdfd1982 cdfd1982 is offline Offline
Newbie Poster

Re: To parse through the file and print output using awk or sed script

 
0
  #5
Mar 3rd, 2008
Originally Posted by eggi View Post
Hey There,

Are there always only 2 mismatched letters in each pair of rows? Just wondering if you do multiple colons before full stop and how you handle that.

Also, can you post what you have so far? Just curious as to where you're having the issue.

Thanks

, Mike
Thanks for looking into the question
Actually u can say this is a part of sequence alignment ( biology) where amino acids of one sequence aligns with amino acids of another sequence Say between human and chimpanzee
so those amino aicid match thatwill give asterisk
otherwise colon or fullstop ( this is by software program which can produce that)
.

can u produce a script if u look into the question previously posted if possible.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 17
Reputation: rikxik is an unknown quantity at this point 
Solved Threads: 3
rikxik rikxik is offline Offline
Newbie Poster

Re: To parse through the file and print output using awk or sed script

 
0
  #6
Mar 12th, 2008
Sorry, I know awk/sed was requested, but a python solution was so easy, couldn't help to post it:

Shell Scripting Syntax (Toggle Plain Text)
  1. #!python
  2.  
  3. (a, b) = ([], [])
  4. (i,j)=(1,1)
  5. diffchar=['.',':']
  6.  
  7. for line in open("sq.txt"):
  8. line=line.strip()
  9. if i == 1:
  10. a = list(line)
  11. elif i == 2:
  12. b = list(line)
  13. elif i == 3:
  14. for (x,k) in enumerate(list(line.replace(' ',''))):
  15. if (k in diffchar):
  16. print a[x]+str(j)+b[x]
  17. j+=1
  18.  
  19. i=0
  20. i+=1

Discard if you can't have Python. This may give you some idea about the awk code though (feel too lazy to translate in awk

HTH
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum


Views: 3054 | Replies: 5
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC