tmartin
tmartin

Reputation: 321

open babel: how to create multiple output files (split the input)?

I have a .pdb file containing multiple conformers of the same molecule. Now I want to convert each of those conformers to a separate .xyz file. According to the open babel help, this could be done with the -m option.

-m Produces multiple output files, to allow:
   Splitting: e.g.        babel infile.mol new.smi -m
    puts each molecule into new1.smi new2.smi etc
   Batch conversion: e.g. babel *.mol -osmi -m
    converts each input file to a .smi file

But this converts only the first geometry and then stops:

babel -ipdb confs.pdb -oxyz test.xyz -m
  1 molecule converted
  14 audit log messages

(Tested open babel 2.3.2 on Ubuntu and OSX)

Any suggestion how to fix that or which program to use instead?

Upvotes: 3

Views: 4361

Answers (1)

Adarsh Singh
Adarsh Singh

Reputation: 1

Split your pdb file using this linux command:

grep -n 'MODEL\|ENDMDL' models.pdb | cut -d: -f 1 | \
 awk '{if(NR%2) printf "sed -n %d,",$1+1; else printf "%dp models.pdb > model_%03d.pdb\n", $1-1,NR/2;}' |  bash -sf

Input file is models.pdb, and split file will be named as model_0001.pdb, model_0002.pdb...etc

More details here: https://strucbio.biologie.uni-konstanz.de/ccp4wiki/index.php/Split_NMR-style_multiple_model_pdb_files_into_individual_models

Upvotes: 0

Related Questions