On Tuesday 25 August 2009 01:27:52 Martyn Winn wrote:
> 
> You should be able to do this kind of scripting.
> 
> The CCP4 library will try to add an extension, iff there is not one
> already. But if you have set $tempfile to "foo.pdb" then it shouldn't
> add anything. 

Since several people have expressed confusion at why this is a problem,
let me expand a little.  I have a shell script that works fine
from the command line. Stripped to its essence, it looks like this:

#/bin/bash
#script tls2anisou
/usr/local/bin/tlsextract XYZIN $1 TLSOUT $1.tls
/usr/local/bin/tlsanl XYZIN $1 TLSIN $1.tls XYZOUT $1_bcor.pdb << EOF
BRESID true
ISOOUT full
END
EOF

So from the command line I can type
   tls2anisou myfile.pdb
and all is well.

But now I want to run the script from a cgi script as part of the
processing by a web service.  No matter what the name of the file
that was originally uploaded, the web server has homogenized it to
a local temporary file whose name is generated by a hash function
from the pid.  The cgi script passes this arbitrary file name to
the script in $1, but of course at this point it does not end in
".pdb" and in fact has no extension at all.

My current work-around is the following variant:

#/bin/bash
#
# This script is designed to be called from inside a cgi script,
# so its environment has been stripped.  We need to add back a
# minimal set of environmental variables in order to run CCP4 programs.
#
export CCP4_SCR=/var/www/webtmp
export CLIBD=/dev/null
export CINCL=/var/www/local/include
#
# I have no idea why this is necessary, but the CCP4 programs below
# seem to add a ".brk" on the end of XYZIN filenames
mv $1 $1.brk
#
/usr/local/bin/tlsextract XYZIN $1 TLSOUT $1.tls
/usr/local/bin/tlsanl XYZIN $1 TLSIN $1.tls XYZOUT $1_bcor.pdb << EOF
BRESID true
ISOOUT full
END
EOF

That works, but at the cost of an unnecessary file copy operation.
I was hoping I could set something in $CINCL/environ.def that would
fix the naming problem, but if so I haven't figured it out yet.

> Code is in ccp4_general.c if you want to sabotage it ...

Thanks. I might do that.

> The list of default extensions is in $CCP4/include/environ.def
> (but we obviously need to update .brk to .pdb)

Yeah, I saw that.  That lets you change the default extension, 
but based on my blind experimentation it doesn't let you remove
the extension altogether. Perhaps I didn't try the right thing?
Given the hint to look in ccp4_general.c, I may be able to fix that.

        thanks,

                Ethan



> 
> HTH
> Martyn
> 
> On Mon, 2009-08-24 at 17:30 -0700, Ethan Merritt wrote:
> > Not sure this is the right place to ask, but...
> > 
> > I'm trying to chain some ccp4 programs together via a script.
> > It creates temporary files with arbitrary names based on the process id.
> > The problem is that when I try to pass one of these files to the
> > next program in the chain, as in:
> > 
> >    tlsanl XYZIN $tempfile <<EOF
> >    ...
> >    EOF
> > 
> > The ccp4 libraries seem to expand this to be an input file named
> >    $tempfile.brk
> > 
> > Is there any way to make the programs _not_ append a useless extension
> > ".brk"  in a scripted environment?
> > 
> -- 
> ***********************************************************************
> *                                                                     *
> *               Dr. Martyn Winn                                       *
> *                                                                     *
> *   STFC Daresbury Laboratory, Daresbury, Warrington, WA4 4AD, U.K.   *
> *   Tel: +44 1925 603455    E-mail: martyn.w...@stfc.ac.uk            *
> *   Fax: +44 1925 603825    Skype name: martyn.winn                   * 
> *             URL: http://www.ccp4.ac.uk/martyn/                      *
> ***********************************************************************
> 
> 



-- 
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle 98195-7742

Reply via email to