*** For details on how to be removed from this list visit the ***
*** CCP4 home page http://www.ccp4.ac.uk ***
Hi James,
This could be considered to be a bit of a hack, but will probably do the
trick:
make a jiffy that
1. generates the list of files for you given a certain directory
2. and runs your program
Something like this should do the trick i think (and oh yes, its in python):
import os, sys
def run(args):
pathname = "."
if len(args)>0:
pathname=args[0]
for file_name in os.listdir(pathname):
#maybe put a check if this is a pdb file
# this is not a very smart way of doing it btw
if ".ent" in file_name:
print "hoera! "
#make the string that you want to execute
my_command = """my_clever_program pdb_in %s"""%(
os.path.join( pathname, file_name) )
print my_command
#make a system call to execute my_command
os.system( my_command )
print "done"
if __name__ =="__main__":
run(sys.argv[1:])
running this on my home directory gives me something like:
rosie:/net/cci/phzwart % python tmp.py ~/
hoera!
my_clever_program pdb_in /net/cci/phzwart/pdb1thw.ent
sh: my_clever_program: command not found
I bet there are a gazillion other ways (i.e. different scripting
languages) of doing this.
I prefer python because I know how to do stuff with it and have
appropriate libraries do read in and do stuff with pdb files (not shown
above, but can send you an example if you want). If you are interested,
have a look at
http://phenix-online.org/cctbx_sources/iotbx/iotbx/pdb/
to see some code related to reading in PDB files and building a
hierarchy (model,chain,conformer,residue,atom) from it.
If you are fixed on C++ (i can see why) the MMDB is a good thing to use
as well:
http://www.ebi.ac.uk/~keb/cldoc/
Another helpfull source of code that comes to mind is the minimol
library within clipper:
http://www.ysbl.york.ac.uk/~cowtan/clipper/doc/minimol/
The possibilities are endless it seems ....
HTH
Peter
James Hengenius wrote:
Hello All,
I'm currently writing a short program which extracts and compares
certain structural elements from .pdb files.
I've been using C++ for convenience (I'm more familiar with that
language than others), but I've run into a snag. C++ does not seem to
have a simple means of evaluating all files in a directory if it is
given a directory path.
I was going to work around this by including a text file with each
directory's .pdb file names along with the .pdb files. Then, given a
directory path, the program could read in the individual file names from
the directory's text file and append them to the directory path. This
would allow it to evaluate each .pdb in a given directory.
However, this requires manually adjusting the included text file any
time .pdb files are added or removed from the folder; it can be time
consuming.
Does anyone here know of a coding solution that would allow a C++
program to evaluate a directory's files (and possibly even
subdirectories' files) without a clumsy work-around described above?
Thanks in advance,
Jim H.