Question regarding Bash program

Thread Tools Search this Thread
Top Forums Programming Question regarding Bash program
# 1  
Old 10-05-2013
Question regarding Bash program

Hello All,

I am trying to write a small bash script to make my life easier for an analysis. I have multiple folders and inside them are 10 output files with an extension .pdbqt What I am trying to do is to read the folder content and then make a PyMol (.pml) file to load the molecules and then display it. When I close the PyMol, the script should go to the next folder and do the same thing again. Below I am pasting the code, any help is greatly appreciated Smilie
for f in Frog-mol-ryan_*; do
    if [ -d "${f}" ]; then
        echo Loading structures in Pymol: $f
cat <<EOF >log.pml                                                                                                                                                                           
load /server/John/Docking-Studies/docking-FC996-analog/MR1004/test/Frog-mol-ryan_*/out_Frog-ryan-mol_ligand_*.pdbqt                                                            
load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/PDBs/Holo-with-Bpore.pdb                                                                                
cmd.hide("everything","holo-with-Bpore")                                                                                                                                        "cartoon"   ,"holo-with-Bpore")                                                                                                                                        "sticks", "out_Frog-mol-ryan_ligand_*.pdbqt")                                                                                                                                                   

/usr/bin/pymol log.pml

The output log.pml is:
load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/MR1004/test/Frog-mol-ryan_*/out__ligand_*.pdbqt

load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/PDBs/Holo-with-Bpore.pdb
cmd.hide("everything","holo-with-Bpore")"cartoon"   ,"holo-with-Bpore")"sticks", "out__ligand_*.pdbqt")

I am not able to pass the argument in cat EOF section.

Kindly help

Last edited by jim mcnamara; 10-05-2013 at 10:51 PM..
# 2  
Old 10-06-2013
You've passed hardcoded text, rather than the variable $f..
load /server/John/Docking-Studies/docking-FC996-analog/MR1004/test/Frog-mol-ryan_*/out_Frog-ryan-mol_ligand_*.pdbqt

load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/MR1004/test/$f/out_$f*.pdbqt

Assuming the "out_Frog_ryan_mol" was a typo and should have been "out_Frog_mol_ryan"...

Hope this helps

Last edited by Don Cragun; 10-06-2013 at 03:17 AM.. Reason: Change ICODE tags to CODE tags for pathnames that should not be split into multiple lines
# 3  
Old 10-06-2013
Hello sea,
Thank you for your help. One small problem, the output files are named out_Frog-mol-ryan_ligand_05.pdbqt so if I set as "$f/out_$f*.pdbqt" its not able to find the files.
Kindly suggest.

# 4  
Old 10-06-2013
Oh the assumption was wrong Smilie

This should do the trick then:
load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/MR1004/test/$f/out_Frog-mol-ryan_ligand_*.pdbq
# 5  
Old 10-06-2013
Thanks sea,
Sorry to disturb you so much.
"out_Frog-mol-ryan_ligand_*.pdbq" is not getting translated in the log.pml file so the visualizer is not able to understand the "*" explicitly.

Let me explain the structure of directories. I have 100 folders named "Frog-mol-ryan_1, Frog-mol-ryan_2, Frog-mol-ryan_3 ... and so on till out_Frog-ryan-mol_ligand_100. Now each folder has 20 output files named "out_Frog-ryan-mol_ligand_1.pdbqt, out_Frog-ryan-mol_ligand_2.pdbqt .... and so on till out_Frog-ryan-mol_ligand_20.pdbqt". What I am trying to do is to make a bash script file which will go inside each folder (Frog-ryan-mol_1), grab all the "out_*.pdbqt" files and write a log.pml file with instructions to load all the molecules in the PyMol. Now after loading the molecules in PyMol, when I close the PyMol window the script will go to the next folder (Frog-ryan-mol_2) and do the same thing as the previous one.

Thank you so much for your time and patience Smilie
# 6  
Old 10-06-2013
Can you show us how should a single log.pml look like for a single directory?
# 7  
Old 10-06-2013
cat <<EOF >log.pml

load /server/John/Docking-Studies/docking-FC996-analog/MR1004/test/Frog-mol-ryan_*/out_Frog-ryan-mol_ligand_*.pdbqt

load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/PDBs/Holo-with-Bpore.pdb
cmd.hide("everything","holo-with-Bpore")"cartoon" ,"holo-with-Bpore")"sticks", "out_Frog-mol-ryan_ligand_*.pdbqt")

/usr/bin/pymol log.pml
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Bash Scripting program

#! /bin/bash # program to creat a backup copy for every deleted file or dierctores mv -t /home/$USER/.local/share/Trash/files $1 rsync -a /home/$USER/.local/share/Trash/files /usr/share/trash didn't work (2 Replies)
Discussion started by: rami-ali
2 Replies

2. Shell Programming and Scripting

Question regarding whence program

Hi all, In production code, if using the whence command it picks the production file.if I am using the test code file. by using whence command it not picking the file. do you have any idea on this. Whence prodcode it picks the exact path of the prodcode. whence testcode. it... (1 Reply)
Discussion started by: ramkumar15
1 Replies

3. UNIX for Dummies Questions & Answers

Kill a program from bash

to kill a program in bash, for instance 'mousepad' I use kill $(pidof mousepad); or pkill mousepad But it only works if we use another bash window; If it is started from the same bash, that does not work: #mousepad;kill $(pidof mousepad); In this case, it looks like mousepad hangs... (7 Replies)
Discussion started by: arpagon
7 Replies

4. Programming

Putting bash script in C program

suppose i have a bash script: #!/bin/bash echo "hello" echo "how are you" echo "today" how can i put the entire script above into a basic c program? i do not want to translate the bash code to a c code. i want C to run the bash code. is this possible? i found this on the... (15 Replies)
Discussion started by: SkySmart
15 Replies

5. Shell Programming and Scripting

Creating Printing Program in bash

HI I am trying to create a bash script to print whatever i type in It has to have these below to define the size of the label and what size to print the text N q609 A100,10,0,5,2,2,N," " P1 It has to be sent to below > /dev/usblp0 So what it has to be is Written... (12 Replies)
Discussion started by: bganse
12 Replies

6. Shell Programming and Scripting

Display output bash program

Hello, i have a problem with the output from my bash program. I made this program #!/bin/bash BESTANDEN=$* # Plaatst bestanden in de variabele BESTANDEN$$.$RANDOM # basisnaam voor tijdelijke bestanden # controller of het programma correct is aangeroepen if then ... (6 Replies)
Discussion started by: dutchspiders
6 Replies

7. Shell Programming and Scripting

Program Bash VERY URGENT

Hello I have to do a program in Bash, need help because it does not go out for me and go enough time with this!! Five directories(boards of directors) that more occupy, arranged according to size. To measure the size of every directory(board of directors) there must not be included the size... (1 Reply)
Discussion started by: danihj
1 Replies

8. Shell Programming and Scripting


Hola tengo que hacer un programa en Bash, necesito ayuda porque no me sale y llevo bastante tiempo con esto!! Los cinco directorios que más ocupan, ordenados según tamaño. Para medir el tamaño de cada directorio no debe incluirse el tamaño de sus subdirectorios. Los diez archivos normales que más... (1 Reply)
Discussion started by: danihj
1 Replies

9. Shell Programming and Scripting

[bash] Run a program many times

Hi I'm running a program many times with differents input. I mean that i run my_prog with some parameters and i wait till the end, then i start again another simulations with some others differents parameters. Is possible to make it automatic with a script bash. Maybe i need some... (2 Replies)
Discussion started by: Dedalus
2 Replies

10. Shell Programming and Scripting

BASH: how to launch a program with parameters

Hi, I'm a pretty big fan of BASH scripting. I've got a bunch I use for random things and lately a couple issues have been plaguing me. Both are somewhat related, in that they deal with filenames with spaces and "escaped" characters and with launching a program with command line arguements... (5 Replies)
Discussion started by: TinCanFury
5 Replies
Login or Register to Ask a Question