def makeIndexFile(self,
                      grofile,
                      ndxfile,
                      protein=True,
                      ions=True,
                      sol=True,
                      bath=True,
                      system=True,
                      debug=False):
        """Reads in the grofile, and make an *.ndx file with atom groups corresponding to a list of commmon-sense names
	given in the groups=[] list.  
	
	REQUIRED
	grofile   - gromacs structure filename from which to compile the atom groups
	ndxfile   - filename to write the index file to 
	
	Supported group names so far:
	
	    protein            All protein atoms
	    sol                All solvent atoms.  (protein + sol + ions) shouuld equal (system) !
	    ions               All ions
	    bath               (sol + ions)
	    system             All atoms
	    
	Note: This subroutine assumes it's being called from the current working directory
	
	OUTPUT
	Writes an index file to the given filename. 
	"""

        ndx = IndexFile()

        all_indices = ndx.getAtomListFromGrofile(grofile)
        ion_indices = ndx.getAtomListFromGrofile(
            grofile, ResName=['Na', 'Cl', 'Na+', 'Cl-', 'Mg', 'Ca'])
        sol_indices = ndx.getAtomListFromGrofile(grofile,
                                                 ResName=['SOL', 'HOH'])

        # The protein indices are considered to be all the residues besides ions and solvent
        protein_indices = [
            i for i in all_indices
            if (ion_indices.count(i) == 0 and sol_indices.count(i) == 0)
        ]

        # The bath is just the ions plus the solvent
        bath_indices = ion_indices + sol_indices

        # Create the index file groups
        ndx.addIndexGroup('protein', protein_indices)
        ndx.addIndexGroup('sol', sol_indices)
        ndx.addIndexGroup('ions', ion_indices)
        ndx.addIndexGroup('bath', bath_indices)
        ndx.addIndexGroup('system', all_indices)

        # write the ndxfile
        ndx.writeIndexFile(ndxfile)
Пример #2
0
    def make_ndx(self, grofile, ndxfile, protein=True, ions=True, sol=True, bath=True, system=True, debug=False):
    
	"""Make an *.ndx file with atom groups corresponding to a list of commmon-sense names
	given in the groups=[] list.  Supported group names so far:
	
	    protein            All protein atoms
	    sol                All solvent atoms.  (protein + sol + ions) shouuld equal (system) !
	    ions               All ions
	    bath               (sol + ions)
	    system             All atoms
	    
	Note: This subroutine assumes it's being called from the current working directory
	"""
     
        ndx = IndexFile()
	
	all_indices = ndx.getAtomListFromGrofile(grofile)
	ion_indices = ndx.getAtomListFromGrofile(grofile, ResName=['Na','Cl','Na+','Cl-','Mg','Ca'])
	sol_indices = ndx.getAtomListFromGrofile(grofile, ResName=['SOL','HOH'])
	
	# The protein indices are considered to be all the residues besides ions and solvent
	protein_indices = [i for i in all_indices if (ion_indices.count(i) == 0 and sol_indices.count(i) == 0) ]
	
	# The bath is just the ions plus the solvent
	bath_indices = ion_indices + sol_indices
	
	# Create the index file groups
	ndx.addIndexGroup('protein', protein_indices)
	ndx.addIndexGroup('sol', sol_indices)
	ndx.addIndexGroup('ions', ion_indices)
	ndx.addIndexGroup('bath', bath_indices)
	ndx.addIndexGroup('system', all_indices)

	# write the ndxfile 
	ndx.writeIndexFile(ndxfile)