How to pass a single quote to the program?

Dear forum members,

My question is simple. I want to pass a single quote (') to be read as belonging as an addition to the letters C1', C2', C3', C4', C5', O1', O2', O3', O4' & O5' to the program voronota query-contacts which would be run through shell script and should print out numerical values. I tried writing C1\', C2\', C3\', etc. but am getting no results (blank when I am expecting numbers). Thus the question is how could I pass these letters with a single quote as an argument to voronota query-contacts command? The script is this:

#!/bin/bash
read -p "amino acid: " AAA
if [[ "ALA ARG ASN ASP CYS GLN GLY GLU HIS ILE \
	   LEU LYS MET PHE PRO SER THR TRP TYR VAL" =~ $AAA ]]
then
	for i in HS_*.pdb; 
		do
    		cat $i | voronota get-balls-from-atoms-file --annotated \
    			   | voronota calculate-contacts --annotated \
	    		   | voronota query-contacts --inter-residue --match-first "'R<$AAA>'" \
	    		   --match-second 'A<C1', C2' ,C3' ,C4' ,C5',O1 , O2, O3, O4, O5, O1',O2',O3',O4',O5',N1,N2,N3,C1,C2,C3,C4,C5>'  \
    		   	   | awk '{sum += $3} END {print sum}'
		done
else
	exit 1
fi

The output through command line in all the ways described I get is a blank one:


Thank you very much for your help. I will look forward to your responses.

Yours Sincerely,
Aurimas

Try enclosing the expression in double quotes (as you did with "'R<$AAA>'" ).

Still no results. :-(. Any other way?

Difficult to believe. Show what you did and the results thereof.

1 Like

My input was:

#!/bin/bash
read -p "amino acid: " AAA
if [[ "ALA ARG ASN ASP CYS GLN GLY GLU HIS ILE \
	   LEU LYS MET PHE PRO SER THR TRP TYR VAL" =~ $AAA ]]
then
	for i in HS_*.pdb; 
		do
    		cat $i | voronota get-balls-from-atoms-file --annotated \
    			   | voronota calculate-contacts --annotated \
    			   | voronota query-contacts --inter-residue --match-first "'R<$AAA>'" --match-second "'A<C1',C2',C3',C4',C5',O1,O2,O3,O4,O5,O1',O2',O3',O4',O5',N1,N2,N3,C1,C2,C3,C4,C5>'" \
    			   | awk '{sum += $3} END {print sum}'
		done
else
	exit 1
fi

Then I wrote ./voronota_improved_interface_atoms.sh
When asked for amino acid: I entered ALA and the answer given was 28 blank values:


So apperently single quote is not passed as an argument unless I am doing something wrong :confused:

You definitely need to split your pipeline into single commands and analyse each one of them separately in order to identify what is going wrong. I don't know the voronota command, what it requires, and what its outputs should look like, but piping some file through three instances of it is somewhat new to me.

Re. your single quote question, to me the double quoting seems to do exactly what you need. echo ing your third voronota command with the respective variables and quoting yields:

echo voronota query-contacts --inter-residue --match-first "'R<$AAA>'" --match-second "'A<C1',C2',C3',C4',C5',O1,O2,O3,O4,O5,O1',O2',O3',O4',O5',N1,N2,N3,C1,C2,C3,C4,C5>'" 
voronota query-contacts --inter-residue --match-first 'R<ALA>' --match-second 'A<C1',C2',C3',C4',C5',O1,O2,O3,O4,O5,O1',O2',O3',O4',O5',N1,N2,N3,C1,C2,C3,C4,C5>'
2 Likes

I figured out that my input statement was a bit wrong. So no worries. Your suggestion worked. Thanks!

An alternative might be something like this:

#!/bin/sh
SQ="'"
echo "${SQ}A<C1${SQ}, C2${SQ} ,C3${SQ} ,C4${SQ} ,C5${SQ},O1 ,......"

Result: OSAX 10.14.3, default [bash/]shell terminal.

bazza@amiga-MacBookPro:~$ cd Desktop/Code/Shell
bazza@amiga-MacBookPro:~/Desktop/Code/Shell$ chmod 755 Single_Quote.sh
bazza@amiga-MacBookPro:~/Desktop/Code/Shell$ ./Single_Quote.sh
'A<C1', C2' ,C3' ,C4' ,C5',O1 ,......
bazza@amiga-MacBookPro:~/Desktop/Code/Shell$