PEATSA/Core/Utilities.py
def CleanPDB2PQR(inputFile, outputFile, forceField="amber", removeWater=True, removeLigand=True, removeAltLoc=True, addHydrogens=True, correct=True):

	'''Cleans a PDB by using PDB2PQR
	
	See CleanPDB for argument details

	Note: With pdb2pqr you cannot remove-water or ligands.
		
	Errors: 
		Raises an exception if the inputFile is not a valid PDB file.'''

	import Protool

	try:
		command = 'pdb2pqr --chain --ff=%s' % (forceField)

		if removeWater == True:
			print >>sys.stderr, 'Warn: Currently PDB2PQR does not remove waters from pdb files'

		if removeLigand == True:
			print >>sys.stderr, 'Warn: Currently PDB2PQR can not be used to remove heterogens from PDB files'

		if addHydrogens == False:
			print >>sys.stderr, 'Warn: Turning of Hydrogen addition with PDB2PQR automatically turns of rotamer correction'
			command = command + " --clean "
		else:
			if correct == False:
				command = command + " --nodebump "

		#Protool ignores altlocs so we can use it to remove them 
		#Do this first as Protool as when protool reads then writes a pdb2pqr cleaned file 
		#it raises an error on reading it again 
		if removeAltLoc is True:
			pdb = Protool.structureIO()
			pdb.readpdb(inputFile)
			pdb.writepdb(outputFile)

			inputFile = outputFile

		command = command + ' %s %s' % (inputFile, outputFile)
		print 'Using: ', command

		process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
		stdout, stderr = process.communicate()

		if process.returncode != 0:
			raise ProteinDesignToolException, 'Error using pdb2pqr to clean pdb file %s' % inputFile
		
	except BaseException, data:
		print 'Encountered an exception cleaning pdb %s' % inputFile
		if stdout is not None:
			print 'PDB2PQR output follows:'
			print stdout
		
		raise 			

	print 'FINSIHED'
Cleans a PDB by using PDB2PQR
	
	See CleanPDB for argument details

	Note: With pdb2pqr you cannot remove-water or ligands.
		
	Errors: 
		Raises an exception if the inputFile is not a valid PDB file.
Cleans a PDB by using PDB2PQR
See CleanPDB for argument details

With pdb2pqr you cannot remove-water or ligands.

Raises an exception if the inputFile is not a valid PDB file.
Cleans a PDB by using PDB2PQR See CleanPDB for argument details With pdb2pqr you cannot remove - water or ligands . Raises an exception if the inputFile is not a valid PDB file .
def CleanPDB2PQR(inputFile, outputFile, forceField="amber", removeWater=True, removeLigand=True, removeAltLoc=True, addHydrogens=True, correct=True):
	import Protool
	try:
		command = 'pdb2pqr --chain --ff=%s' % (forceField)
		if removeWater == True:
			print >>sys.stderr, 'Warn: Currently PDB2PQR does not remove waters from pdb files'
		if removeLigand == True:
			print >>sys.stderr, 'Warn: Currently PDB2PQR can not be used to remove heterogens from PDB files'
		if addHydrogens == False:
			print >>sys.stderr, 'Warn: Turning of Hydrogen addition with PDB2PQR automatically turns of rotamer correction'
			command = command + " --clean "
		else:
			if correct == False:
				command = command + " --nodebump "
		if removeAltLoc is True:
			pdb = Protool.structureIO()
			pdb.readpdb(inputFile)
			pdb.writepdb(outputFile)
			inputFile = outputFile
		command = command + ' %s %s' % (inputFile, outputFile)
		print 'Using: ', command
		process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
		stdout, stderr = process.communicate()
		if process.returncode != 0:
			raise ProteinDesignToolException, 'Error using pdb2pqr to clean pdb file %s' % inputFile
	except BaseException, data:
		print 'Encountered an exception cleaning pdb %s' % inputFile
		if stdout is not None:
			print 'PDB2PQR output follows:'
			print stdout
		raise 			
	print 'FINSIHED'
def CleanPDB2PQR ( inputFile , outputFile , forceField = "amber" , removeWater = True , removeLigand = True , removeAltLoc = True , addHydrogens = True , correct = True ) : import Protool try : command = 'pdb2pqr --chain --ff=%s' % ( forceField ) if removeWater == True : print >> sys . stderr , 'Warn: Currently PDB2PQR does not remove waters from pdb files' if removeLigand == True : print >> sys . stderr , 'Warn: Currently PDB2PQR can not be used to remove heterogens from PDB files' if addHydrogens == False : print >> sys . stderr , 'Warn: Turning of Hydrogen addition with PDB2PQR automatically turns of rotamer correction' command = command + " --clean " else : if correct == False : command = command + " --nodebump " if removeAltLoc is True : pdb = Protool . structureIO ( ) pdb . readpdb ( inputFile ) pdb . writepdb ( outputFile ) inputFile = outputFile command = command + ' %s %s' % ( inputFile , outputFile ) print 'Using: ' , command process = subprocess . Popen ( command , shell = True , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) stdout , stderr = process . communicate ( ) if process . returncode != 0 : raise ProteinDesignToolException , 'Error using pdb2pqr to clean pdb file %s' % inputFile except BaseException , data : print 'Encountered an exception cleaning pdb %s' % inputFile if stdout is not None : print 'PDB2PQR output follows:' print stdout raise print 'FINSIHED'
Cleans a PDB by using PDB2PQR
See CleanPDB for argument details
Cleans a PDB by using PDB2PQR See CleanPDB for argument details
'''Cleans a PDB by using PDB2PQR
	
	See CleanPDB for argument details

	Note: With pdb2pqr you cannot remove-water or ligands.
		
	Errors: 
		Raises an exception if the inputFile is not a valid PDB file.''' #Protool ignores altlocs so we can use it to remove them  #Do this first as Protool as when protool reads then writes a pdb2pqr cleaned file  #it raises an error on reading it again 
inputFile
outputFile
forceField
removeWater
removeLigand
removeAltLoc
addHydrogens
correct