Saturday 31 December 2011

Script problem



From: Simon Kolstoe


Hi there,

I've got a text file with multiple conformations of a ligand that has been docked to a protein using autodock, which I am trying to split into separate pdb files in order to visualise in pymol/coot etc.

Previously I've used the script pasted below, but it is now falling over just after it creates the pdb file with the error:

expr: syntax error
csplit: }: bad repetition count
./split_results.com: line 11: syntax error near unexpected token `('
./split_results.com: line 11: `foreach f ($outputname.[0-9][0-9][0-9])'

Can any of you wizzy programmers give me a hand with getting this to work again? (it's on a mac just in the normal terminal)

Thanks,

Simon

The script:

#!
grep '^DOCKED' output.dlg | cut -c9- > my_docking.pdbqt
cut -c-66 my_docking.pdbqt > my_docking.pdb
# csh to split pdb files from autodock output.
# edit outputname.
#
set outputname=output
set a=`grep ENDMDL my_docking.pdb | wc -l`
set b=`expr $a - 2`
csplit -k -s -n 3 -f $outputname. my_docking.pdb '/^ENDMDL/+1' '{'$b'}'
foreach f ($outputname.[0-9][0-9][0-9])
mv $f $f.pdb
end

----------
From: Ian Tickle

Simon

This appears to be a csh or tcsh script: if so the first line must be
"#!/bin/csh" or "#!/bin/tcsh", otherwise it takes it to be a sh
script.

Cheers

-- Ian

----------
From: Paul Emsley


This doesn't answer your question.

But I'd just do it in Coot:

(define (split-multi-alt-confs)
 (using-active-atom
 (let ((alt-confs (residue-alt-confs aa-imol aa-chain-id aa-res-no aa-ins-code)))
   (for-each (lambda (alt-conf)
       (let* ((ss (string-append "//*/*/*: ," alt-conf ""))
              (imol-new (new-molecule-by-atom-selection aa-imol ss))
              (new-name (string-append (strip-extension (molecule-name aa-imol))
                       "-alt-conf-" alt-conf)))
         (set-molecule-name imol-new new-name)))
         (residue-alt-confs aa-imol aa-chain-id aa-res-no aa-ins-code)))))


Centre on your interesting ligand with multiple alt-confs and then use scripting -> scheme

(split-multi-alt-confs)

If you want to write out the various pdb files, you can add in a
(write-pdb-file imol-new (string-append (molecule-name imol-new) ".pdb"))
before the set-molecule-name... line.

Paul.


No comments:

Post a Comment