mittinatten / freesasa

C-library for calculating Solvent Accessible Surface Areas
http://freesasa.github.io/
MIT License
105 stars 37 forks source link

Problems with PDB output using --separate-models #25

Closed mittinatten closed 7 years ago

mittinatten commented 7 years ago

Only the first model is included in the PDB output when using the CLI option --separate-models (see #24).

drjsoundsgood commented 7 years ago

Thanks for looking into this. In the meantime, I wrote a few scripts to get it done, so no rush/worries if you don't have time to look into it now.

I separate the models:

`import re

with open('4nyg.pdb', 'r') as f: data = f.read()

found = re.findall(r'\n(MODEL.?ENDMDL)\n*', data, re.M | re.S)

[open(str(i)+'.pdb', 'w').write(found[i-1]) for i in range(1, len(found)+1)]`

Then I run a bash command:

for i in *.pdb; do freesasa --format=pdb "$i" > $i.out; done

Then I put everything back together:

`import glob

read_files = glob.glob("*.out")

with open("result.txt", "wb") as outfile: for f in read_files: with open(f, "rb") as infile: outfile.write(infile.read())`

mittinatten commented 7 years ago

Hi again, Turns out the fix only involved a very minor change. 28d7e1d should fix this (in the dev-branch). I'll close the issue, feel free to reopen if the patch doesn't work as expected.

mittinatten commented 7 years ago

Merged the fix into the master branch too