Skip to content
Snippets Groups Projects
Commit 38e0537e authored by juergen's avatar juergen
Browse files

adding missing implementation for pdb writer flags

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2108 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 53098faa
Branches
Tags
No related merge requests found
...@@ -20,27 +20,27 @@ from _io import * ...@@ -20,27 +20,27 @@ from _io import *
from ost import mol,conop from ost import mol,conop
def LoadPDB(filename, restrict_chains="", no_hetatms=False, def LoadPDB(filename, restrict_chains="", no_hetatms=False,
fault_tolerant=False, load_multi=False, fault_tolerant=False, load_multi=False,
join_spread_atom_records=False): join_spread_atom_records=False):
""" """
Load PDB file from disk. Load PDB file from disk.
If restrict_chains is not an empty string, only chains listed in the If restrict_chains is not an empty string, only chains listed in the
string will be imported. string will be imported.
If fault_tolerant is set to true, the import will succeed, even if the If fault_tolerant is set to true, the import will succeed, even if the
PDB contains faulty records. The faulty records will be ignored in that PDB contains faulty records. The faulty records will be ignored in that
case. case.
If not_hetatms is set to True, HETATM records will be ignored If not_hetatms is set to True, HETATM records will be ignored
If load_multi is set to true, a list of entities will be returned instead If load_multi is set to true, a list of entities will be returned instead
of only the first. of only the first.
If join_spread_atom_records is set to true, atom records belonging to the If join_spread_atom_records is set to true, atom records belonging to the
same residue are joined, even if they do not appear sequentially in the PDB same residue are joined, even if they do not appear sequentially in the PDB
file. file.
""" """
conop_inst=conop.Conopology.Instance() conop_inst=conop.Conopology.Instance()
builder=conop_inst.GetBuilder("DEFAULT") builder=conop_inst.GetBuilder("DEFAULT")
reader=PDBReader(filename) reader=PDBReader(filename)
...@@ -64,7 +64,7 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=False, ...@@ -64,7 +64,7 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=False,
PDB.PopFlags() PDB.PopFlags()
return ent_list return ent_list
else: else:
ent=mol.CreateEntity() ent=mol.CreateEntity()
if reader.HasNext(): if reader.HasNext():
reader.Import(ent, restrict_chains) reader.Import(ent, restrict_chains)
conop_inst.ConnectAll(builder, ent, 0) conop_inst.ConnectAll(builder, ent, 0)
...@@ -81,18 +81,24 @@ def SavePDB(models, filename): ...@@ -81,18 +81,24 @@ def SavePDB(models, filename):
if not getattr(models, '__len__', None): if not getattr(models, '__len__', None):
models=[models] models=[models]
writer=PDBWriter(filename) writer=PDBWriter(filename)
if len(models)>1: try:
writer.SetFlags(PDB.WRITE_MULTIPLE_MODELS) if len(models)>1:
for model in models: PDB.PushFlags(PDB.Flags() |PDB.WRITE_MULTIPLE_MODELS)
writer.Write(model) else:
PDB.PushFlags(0)
for model in models:
writer.Write(model)
PDB.PopFlags()
except:
PDB.PopFlags()
raise
try: try:
from ost import img from ost import img
LoadMap = LoadImage LoadMap = LoadImage
SaveMap = SaveImage SaveMap = SaveImage
except ImportError: except ImportError:
pass pass
## loads several images and puts them in an ImageList ## loads several images and puts them in an ImageList
# \sa \ref fft_li.py "View Fourier Transform Example" # \sa \ref fft_li.py "View Fourier Transform Example"
def LoadImageList (files): def LoadImageList (files):
...@@ -100,14 +106,14 @@ def LoadImageList (files): ...@@ -100,14 +106,14 @@ def LoadImageList (files):
for file in files: for file in files:
image=LoadImage(file) image=LoadImage(file)
image_list.append(image) image_list.append(image)
return image_list return image_list
LoadMapList=LoadImageList LoadMapList=LoadImageList
## \example fft_li.py ## \example fft_li.py
# #
# This scripts loads one or more images and shows their Fourier Transforms on the screen. A viewer # This scripts loads one or more images and shows their Fourier Transforms on the screen. A viewer
# is opened for each loaded image. The Fourier Transform honors the origin of the reference system, # is opened for each loaded image. The Fourier Transform honors the origin of the reference system,
# which is assumed to be at the center of the image. # which is assumed to be at the center of the image.
# #
# Usage: # Usage:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment