# Calculate the volume of each connected surface component and then delete # all but the largest component. # Find all surface models from chimera import openModels from _surface import SurfaceModel surfs = openModels.list(modelTypes = [SurfaceModel]) # Divide surface into connected pieces, report volumes, delete all but largest. from Surface import actions from MeasureVolume import enclosed_volume for s in surfs: pieces = [] for p in s.surfacePieces: # Split surface piece into connected components. cplist = actions.split_surface_piece(p) for cp in cplist: # Calculate volume. varray, tarray = cp.geometry v, holes = enclosed_volume(varray, tarray) if holes == 0: pieces.append((v, cp)) if pieces: # Print volumes. pieces.sort() pieces.reverse() volumes = ', '.join(['%.3g' % v for v,p in pieces]) print 'Volumes ', volumes # Delete all but largest volume piece. v0, p0 = pieces[0] for p in s.surfacePieces: if p != p0: s.removePiece(p)