Author: bugman
Date: Fri Jan 30 12:23:40 2015
New Revision: 27388
URL: http://svn.gna.org/viewcvs/relax?rev=27388&view=rev
Log:
Shifted the data_store.seq_align.Alignment.generate_id() method into the relax
library.
It has been converted into the lib.structure.internal.coordinates.generate_id()
function to allow
for greater reuse.
Modified:
trunk/data_store/seq_align.py
trunk/lib/structure/internal/coordinates.py
Modified: trunk/data_store/seq_align.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/data_store/seq_align.py?rev=27388&r1=27387&r2=27388&view=diff
==============================================================================
--- trunk/data_store/seq_align.py (original)
+++ trunk/data_store/seq_align.py Fri Jan 30 12:23:40 2015
@@ -25,6 +25,7 @@
# relax module imports.
from data_store.data_classes import Element, RelaxListType
from lib.errors import RelaxError
+from lib.structure.internal.coordinates import generate_id
class Sequence_alignments(RelaxListType):
@@ -192,7 +193,7 @@
# Create a unique ID for each molecule.
self.ids = []
for i in range(len(self.object_ids)):
- self.ids.append(self.generate_id(object_id=self.object_ids[i],
model=self.models[i], molecule=self.molecules[i]))
+ self.ids.append(generate_id(object_id=self.object_ids[i],
model=self.models[i], molecule=self.molecules[i]))
# Check the IDs for uniqueness.
for i in range(len(self.ids)):
@@ -201,43 +202,3 @@
continue
if self.ids[i] == self.ids[j]:
raise RelaxError("The molecule ID '%s' is not unique." %
self.ids[i])
-
-
- def generate_id(self, object_id=None, model=None, molecule=None):
- """Generate a unique ID.
-
- @keyword object_id: The structural object ID.
- @type object_id: str
- @keyword model: The model number.
- @type model: int
- @keyword molecule: The molecule name.
- @type molecule: str
- @return: The unique ID constructed from the object ID,
model number and molecule name.
- @rtype: str
- """
-
- # Init.
- id = ''
-
- # The object ID.
- if object_id != None:
- id += "Object '%s'" % object_id
-
- # The model number.
- if model != None:
- if len(id):
- id += '; '
- id += "Model %i" % model
-
- # The molecule name.
- if len(id):
- id += '; '
- if molecule != None:
- id += "Molecule '%s'" % molecule
-
- # Sanity check.
- if not len(id):
- raise RelaxError("No alignment ID could be constructed.")
-
- # Return the ID.
- return id
Modified: trunk/lib/structure/internal/coordinates.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/lib/structure/internal/coordinates.py?rev=27388&r1=27387&r2=27388&view=diff
==============================================================================
--- trunk/lib/structure/internal/coordinates.py (original)
+++ trunk/lib/structure/internal/coordinates.py Fri Jan 30 12:23:40 2015
@@ -267,6 +267,46 @@
return coord, ids
+def generate_id(object_id=None, model=None, molecule=None):
+ """Generate a unique ID.
+
+ @keyword object_id: The structural object ID.
+ @type object_id: str
+ @keyword model: The model number.
+ @type model: int
+ @keyword molecule: The molecule name.
+ @type molecule: str
+ @return: The unique ID constructed from the object ID, model
number and molecule name.
+ @rtype: str
+ """
+
+ # Init.
+ id = ''
+
+ # The object ID.
+ if object_id != None:
+ id += "Object '%s'" % object_id
+
+ # The model number.
+ if model != None:
+ if len(id):
+ id += '; '
+ id += "Model %i" % model
+
+ # The molecule name.
+ if len(id):
+ id += '; '
+ if molecule != None:
+ id += "Molecule '%s'" % molecule
+
+ # Sanity check.
+ if not len(id):
+ raise RelaxError("No alignment ID could be constructed.")
+
+ # Return the ID.
+ return id
+
+
def loop_coord_structures(objects=None, molecules=None, models=None,
atom_id=None):
"""Generator function for looping over all internal structural objects,
models and molecules.
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits