Question: Bash script error on reading coordinates in a file
0
gravatar for Ali HEBRA
19 months ago by
Ali HEBRA0
Switzerland, Basel
Ali HEBRA0 wrote:

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

bash text-processing pdb • 606 views
ADD COMMENTlink modified 19 months ago by Pierre Lindenbaum113k • written 19 months ago by Ali HEBRA0
1
gravatar for Pierre Lindenbaum
19 months ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum113k wrote:

not

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

but

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

(backquote)

ADD COMMENTlink written 19 months ago by Pierre Lindenbaum113k

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 REPLYlink written 19 months ago by Ali HEBRA0
1

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 REPLYlink modified 19 months ago • written 19 months ago by Medhat7.9k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1281 users visited in the last hour