harmslab / latticeproteins

2d protein lattice model simulator in Python
http://latticeproteins.readthedocs.io/en/latest/
GNU General Public License v3.0
2 stars 7 forks source link

error in tutorial: lp.draw #2

Open volkansevim opened 7 years ago

volkansevim commented 7 years ago

Tutorial fails at the visualization step for some sequences such as ['M', 'I', 'I', 'D', 'C', 'E', 'I', 'T', 'F', 'C'] :

conf = lattice.native_conf(seq)
lp.draw.in_notebook(seq, conf)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-28e56a5fa8fb> in <module>()
      1 conf = lattice.native_conf(seq)
----> 2 lp.draw.in_notebook(seq, conf)

~/Software/latticeproteins/latticeproteins/draw.py in in_notebook(sequence, conf, **kwargs)
     39 def in_notebook(sequence, conf, **kwargs):
     40     """Creates a Python SVG configuration object. Automagically displays in notebook."""
---> 41     drawing = Configuration(sequence, conf, **kwargs)
     42     return drawing
     43 

~/Software/latticeproteins/latticeproteins/draw.py in __init__(self, sequence, configuration, color_sequence, rotation, font_size, dot_scale, font_weight)
    156             self.color_sequence = color_sequence
    157         # Sets rotation and configuration
--> 158         self.rotate(rotation)
    159 
    160     @property

~/Software/latticeproteins/latticeproteins/draw.py in rotate(self, rotation)
    182         for i in range(n):
    183             self.configuration = "".join([ROTATE[c] for c in self.configuration])
--> 184         self._build_drawing()
    185 
    186     def save(self, filename):

~/Software/latticeproteins/latticeproteins/draw.py in _build_drawing(self)
    210     def _build_drawing(self):
    211         """Build drawing object."""
--> 212         self.array = configuration_to_array(self.sequence, self.configuration)
    213         self.color_array = configuration_to_array(self.color_sequence, self.configuration)
    214         # Build SVG grid object

~/Software/latticeproteins/latticeproteins/draw.py in configuration_to_array(sequence, configuration)
     54     xmoves, ymoves = [0], [0]
     55     # Figure out the perimeter of the configuration
---> 56     for i in range(len(configuration)):
     57         move = configuration[i]
     58         xmoves.append(xmoves[i] + moves[move][0])

TypeError: object of type 'NoneType' has no len()
Zsailer commented 7 years ago

This issue is fundamentally different than issue #3. When you see this error, it is because

lattice.native_conf(seq) == None

Practically, this mean the given lattice protein seq does not fold to a single native structure. Put another way, there is degeneracy among the lowest energy conformations.

Currently, this method returns None. Perhaps it should raise an exception. I'll think about that more.

In the meantime, I'll update the tutorial notebook to catch sequences that don't fold.

volkansevim commented 7 years ago

If lowest energy state is degenerate, then shouldn't alt_conf[0] be equal to alt_conf[1]? I'm seeing -21.33 and -20.89.

Zsailer commented 7 years ago

The docs aren't clear about this (I'll update them), but k_lowest_confs returns the k lowest unique conformations. It ignores degenerate states.

Zsailer commented 7 years ago

so, alt_conf[0] and alt_conf[1] will never be the equal. Perhaps I should rename this method k_lowest_unique_confs to be transparent. We can add a new method k_lowest_confs to handle degenerate states

volkansevim commented 7 years ago

I see. Having two different methods is a good idea. Degenerate states are important and they should be reported.