Question regarding Bash program

Tags
bash, programming, script file, shell commands

 
Thread Tools Search this Thread
# 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
Code:
#!/bin/bash                                                                                                                                                                                   
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                                                            
                                                                                                                                                                                              
reset                                                                                                                                                                                         
load /server/John/Docking-Studies/Insilico-mod-FC996/docking-FC996-analog/PDBs/Holo-with-Bpore.pdb                                                                                
cmd.hide("everything","holo-with-Bpore")                                                                                                                                                 
cmd.show("cartoon"   ,"holo-with-Bpore")                                                                                                                                                 
cmd.show("sticks", "out_Frog-mol-ryan_ligand_*.pdbqt")                                                                                                                                                   
EOF                                                                                                                                                                                           

/usr/bin/pymol log.pml
    fi
done

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

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

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

Kindly help
Thanks

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..
Code:
load /server/John/Docking-Studies/docking-FC996-analog/MR1004/test/Frog-mol-ryan_*/out_Frog-ryan-mol_ligand_*.pdbqt

becomes
Code:
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.

Thanks
# 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

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

/usr/bin/pymol log.pml

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Bash Scripting program rami-ali Homework & Coursework Questions 2 11-21-2018 11:57 AM
Question regarding whence program ramkumar15 Shell Programming and Scripting 1 03-27-2015 05:47 PM
Kill a program from bash arpagon UNIX for Dummies Questions & Answers 7 07-25-2014 02:34 PM
Running a C/C++ program and/or bash script from a server frad UNIX for Dummies Questions & Answers 1 12-13-2013 12:50 PM
Hide bash code which is inside C plus plus program frad Shell Programming and Scripting 1 12-09-2013 01:39 PM
Putting bash script in C program SkySmart Programming 15 03-06-2013 06:23 PM
Creating Printing Program in bash bganse Shell Programming and Scripting 12 03-09-2012 03:24 PM
bash script to check if a program is running mcknz Shell Programming and Scripting 3 08-08-2011 09:37 PM
Problem with bash shell script program gskumar1234 Shell Programming and Scripting 7 08-08-2011 07:43 AM
Run Program from Bash CGI-Script JMooney5115 Homework & Coursework Questions 8 01-27-2011 07:51 PM
Display output bash program dutchspiders Shell Programming and Scripting 6 10-18-2010 01:01 PM
Program Bash VERY URGENT danihj Shell Programming and Scripting 1 02-13-2010 10:19 AM
PROGRAM BASH danihj Shell Programming and Scripting 1 02-13-2010 10:11 AM
[bash] Run a program many times Dedalus Shell Programming and Scripting 2 08-17-2009 05:41 PM
BASH: how to launch a program with parameters TinCanFury Shell Programming and Scripting 5 03-15-2008 04:02 AM