Bash script error on reading coordinates in a file
1
0
Entering edit mode
7.1 years ago
Ali HEBRA • 0

Hi guys, Within last few hours I had a problem with extracting coordinates from pdb files in a batch mode with my script. Anyone can suggest me a tricky way to skip that?

my script :

#!/bin/bash
 while read line
 do
 echo $line
  iden=echo $line | awk -F "," {'print $1'}
  pos=echo $line | awk -F "," {'print $2'}
  echo $iden
  file=$iden".pdb"
  x=cat $file | tr 'A' ' ' | awk '/ATOM/ && $3 == "CA" && $4 == "GLU" && $5 == $pos {print $6}'
  y=cat $file | tr 'A' ' ' | awk '/ATOM/ && $3 == "CA" && $4 == "GLU" && $5 == $pos {print $7}'
  z=cat $file | tr 'A' ' ' | awk '/ATOM/ && $3 == "CA" && $4 == "GLU" && $5 == $pos {print $8}'
  echo $iden","$x","$y","$z",," >> loci.csv;
 done < "locations.txt"

and the response in cygwin is :

location.sh: line 6: A0A010PSQ8,182: command not found
location.sh: line 7: A0A010PSQ8,182: command not found

location.sh: line 10: .pdb: command not found
location.sh: line 11: .pdb: command not found
location.sh: line 12: .pdb: command not found

my locations.txt file :

A0A010PSQ8,182

...

Can anybody help me please? I really appreciate an answer that can help me fast

pdb bash text-processing • 1.7k views
ADD COMMENT
1
Entering edit mode
7.1 years ago

not

 iden=echo $line | awk -F "," {'print $1'}

but

 iden=`echo $line | awk -F "," {'print $1'}`

(backquote)

ADD COMMENT
0
Entering edit mode

Thanks a lot for your guidance :) it resolved the first lines of getting identifier and 'pos' but in getting x,y,z coordinates again this error occured :

location.sh: line 9: A0A061QH30.pdb: command not found
location.sh: line 10: A0A061QH30.pdb: command not found
location.sh: line 11: A0A061QH30.pdb: command not found

and i guess this was about not getting the awk command informations. thanks again

ADD REPLY
1
Entering edit mode

As you can see it is the same error, try to put your code line between `` like:

`cat $file | tr 'A' ' ' | awk '/ATOM/ && $3 == "CA" && $4 == "GLU" && $5 == $pos {print $6}'`

The backtick (``) is actually called command substitution. The purpose of command substitution is to evaluate the command which is placed inside the backtick and provide its result as an argument to the actual command.

alternatively you can use $()

ADD REPLY

Login before adding your answer.

Traffic: 1711 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6