def cylinder_and_strand(self):
        '''Display the protein secondary structure as a white,
           solid tube and the alpha-helices as yellow cylinders.

        '''
        top = self.topology
        # We build a  mini-state machine to find the
        # start end of helices and such
        in_helix = False
        helices_starts = []
        helices_ends = []
        coils = []

        coil = []
        for i, typ in enumerate(top['secondary_structure']):
            if typ == 'H':
                if in_helix == False:
                    # We become helices
                    helices_starts.append(top['residue_indices'][i][0])
                    in_helix = True

                    # We end the previous coil
                    coil.append(top['residue_indices'][i][0])
            else:
                if in_helix == True:
                    # We stop being helices
                    helices_ends.append(top['residue_indices'][i][0])

                    # We start a new coil
                    coil = []
                    coils.append(coil)
                    in_helix = False

                # We add control points
                coil.append(top['residue_indices'][i][0])
                [coil.append(j) for j in top['residue_indices'][i] if top['atom_names'][j] == 'CA']

        # We add the coils
        coil_representations = []
        for control_points in coils:
            rid = self.add_representation('smoothtube', {'coordinates': self.coordinates[control_points],
                                                   'radius': 0.05,
                                                   'resolution': 4,
                                                   'color': 0xffffff})
            coil_representations.append(rid)


        start_idx, end_idx = helices_starts, helices_ends
        cylinders = self.add_representation('cylinders', {'startCoords': self.coordinates[list(start_idx)],
                                              'endCoords': self.coordinates[list(end_idx)],
                                              'colors': [0xffff00] * len(self.coordinates),
                                              'radii': [0.15] * len(self.coordinates)})
        def update(self=self, cylinders=cylinders, coils=coils,
                   coil_representations=coil_representations,
                   start_idx=start_idx, end_idx=end_idx, control_points=control_points):
            for i, control_points in enumerate(coils):
                rid = self.update_representation(coil_representations[i],
                                                 {'coordinates': self.coordinates[control_points]})

            self.update_representation(cylinders, {'startCoords': self.coordinates[list(start_idx)],
                                                  'endCoords': self.coordinates[list(end_idx)]})

        self.update_callbacks.append(update)
        self.autozoom(self.coordinates)
def cylinder_and_strand ( self ) : top = self . topology in_helix = False helices_starts = [ ] helices_ends = [ ] coils = [ ] coil = [ ] for i , typ in enumerate ( top [ 'secondary_structure' ] ) : if typ == 'H' : if in_helix == False : helices_starts . append ( top [ 'residue_indices' ] [ i ] [ 0 ] ) in_helix = True coil . append ( top [ 'residue_indices' ] [ i ] [ 0 ] ) else : if in_helix == True : helices_ends . append ( top [ 'residue_indices' ] [ i ] [ 0 ] ) coil = [ ] coils . append ( coil ) in_helix = False coil . append ( top [ 'residue_indices' ] [ i ] [ 0 ] ) [ coil . append ( j ) for j in top [ 'residue_indices' ] [ i ] if top [ 'atom_names' ] [ j ] == 'CA' ] coil_representations = [ ] for control_points in coils : rid = self . add_representation ( 'smoothtube' , { 'coordinates' : self . coordinates [ control_points ] , 'radius' : 0.05 , 'resolution' : 4 , 'color' : 0xffffff } ) coil_representations . append ( rid ) start_idx , end_idx = helices_starts , helices_ends cylinders = self . add_representation ( 'cylinders' , { 'startCoords' : self . coordinates [ list ( start_idx ) ] , 'endCoords' : self . coordinates [ list ( end_idx ) ] , 'colors' : [ 0xffff00 ] * len ( self . coordinates ) , 'radii' : [ 0.15 ] * len ( self . coordinates ) } ) def update ( self = self , cylinders = cylinders , coils = coils , coil_representations = coil_representations , start_idx = start_idx , end_idx = end_idx , control_points = control_points ) : for i , control_points in enumerate ( coils ) : rid = self . update_representation ( coil_representations [ i ] , { 'coordinates' : self . coordinates [ control_points ] } ) self . update_representation ( cylinders , { 'startCoords' : self . coordinates [ list ( start_idx ) ] , 'endCoords' : self . coordinates [ list ( end_idx ) ] } ) self . update_callbacks . append ( update ) self . autozoom ( self . coordinates )
Display the protein secondary structure as a white,
           solid tube and the alpha-helices as yellow cylinders.