Example #1
0
    def defineLigandStructure(self, ligandFile, nameLigand, pathfile=""):
        self.__ligandName = nameLigand

        'Validates path parameters'
        if (pathfile == ""):
            pathfile = self.__resDir

        'Delete Files'
        self.deleteRosettaFiles()

        'Creates mdl file'
        os.system(BABEL_COM + ' -ipdb ' + os.path.join(pathfile, ligandFile) +
                  ' -omdl ' + os.path.join(self.__tmpDir, 'Struct.mdl'))

        'Generates param file'
        os.system(PYTHON_COM +
                  os.path.join(self.__molDir, 'molfile_to_params.py') + ' ' +
                  os.path.join(self.__tmpDir, 'Struct.mdl') + ' -d ' +
                  self.__tmpDir + ' -n ' + self.__ligandName)
        self.__residueSet = rosetta.generate_nonstandard_residue_set(
            [os.path.join(self.__tmpDir, self.__ligandName + '.params')])

        'Generates Ligand'
        self.__ligandFile = IO.readPDB(self.__ligandName + '_0001.pdb',
                                       'HETATM', self.__tmpDir)
        IO.writePDB("ligand.pdb", self.__ligandFile, self.__tmpDir)

        'Init Function'
        self.__scorefxn = rosetta.create_score_function("ligand")
    def generateFinalLog(self):
        self.__timer.stop()

        'Writes Files'
        ligand_PDB_name = "Ligand_score_" + "{0:.3f}".format(self.__scoreFx.getBestScore()) + ".pdb"
        ligandProtein_PDB_name = "LigandProtein_score_" + "{0:.3f}".format(self.__scoreFx.getBestScore()) + ".pdb"
        IO.writePDB(ligand_PDB_name,self.__scoreFx.getBestLigand(),self.__fileDir)
        IO.writeAllPDB(ligandProtein_PDB_name, self.__protein, self.__scoreFx.getBestLigand(), self.__fileDir)

        initLog = "Molecule Name: " + self.__moleculeName + "\n"
        initLog += "Test Pdb: " + self.__testPdb + "\n"
        initLog += "Population: " + str(len(self.population)) + "\n"
        initLog += "Generations: " + str(self.__generations) + "\n"
        initLog += "Time to Stop: " + str(self.__timeStop) + "\n"
        initLog += "Space Size: " + str(self.__spaceLen) + "\n"
        initLog += "Point: ( " + str(self.__spaceCenter[0]) + " , " + str(self.__spaceCenter[1]) + " , " + str(self.__spaceCenter[2]) + " )\n"
        initLog += "Local Search: " + str(self.__localS) + "\n"
        initLog += "Rotate Atoms: " + str(self.__rotateAtoms) + "\n"
        initLog += "\n- Best Score: " + str(self.__scoreFx.getBestScore()) + "\n"
        initLog += "- Reach Best Score: " + str(self.__bestLoop) + "\n"
        auxRMSD = str(self.__scoreFx.getRMSD("original_" + self.__moleculeName + ".pdb", ligandProtein_PDB_name, self.__tmpDir, self.__fileDir))
        initLog += "- RMSD: " + auxRMSD + "\n"
        initLog += "- Timer: " + str(self.__timer.getTimeChronometer()) + "\n" + "\n"
        self.__log = initLog + self.__log

        'Data Log'
        IO.writeLog("iterations.log", self.__log, self.__fileDir)
        IO.writeLog("data.log", self.__dataLog, self.__fileDir)
        IO.writeHistoricLog("historic.log", str(self.__scoreFx.getBestScore()) + ";" + auxRMSD + ";" + str(self.__bestLoop) + ";" + str(self.__loop) , self.__fileDir)

        'Delete files'
        Methods.deleteTempFiles(self.__scoreFx.getLigandName(), self.__moleculeName)
    def generateFinalLog(self):
        self.__timer.stop()

        'Writes Files'
        ligand_PDB_name = "Ligand_score_" + "{0:.3f}".format(
            self.__scoreFx.getBestScore()) + ".pdb"
        ligandProtein_PDB_name = "LigandProtein_score_" + "{0:.3f}".format(
            self.__scoreFx.getBestScore()) + ".pdb"
        IO.writePDB(ligand_PDB_name, self.__scoreFx.getBestLigand(),
                    self.__fileDir)
        IO.writeAllPDB(ligandProtein_PDB_name, self.__protein,
                       self.__scoreFx.getBestLigand(), self.__fileDir)

        initLog = "Molecule Name: " + self.__moleculeName + "\n"
        initLog += "Test Pdb: " + self.__testPdb + "\n"
        initLog += "Population: " + str(len(self.population)) + "\n"
        initLog += "Generations: " + str(self.__generations) + "\n"
        initLog += "Time to Stop: " + str(self.__timeStop) + "\n"
        initLog += "Space Size: " + str(self.__spaceLen) + "\n"
        initLog += "Point: ( " + str(self.__spaceCenter[0]) + " , " + str(
            self.__spaceCenter[1]) + " , " + str(
                self.__spaceCenter[2]) + " )\n"
        initLog += "Local Search: " + str(self.__localS) + "\n"
        initLog += "Rotate Atoms: " + str(self.__rotateAtoms) + "\n"
        initLog += "\n- Best Score: " + str(
            self.__scoreFx.getBestScore()) + "\n"
        initLog += "- Reach Best Score: " + str(self.__bestLoop) + "\n"
        auxRMSD = str(
            self.__scoreFx.getRMSD("original_" + self.__moleculeName + ".pdb",
                                   ligandProtein_PDB_name, self.__tmpDir,
                                   self.__fileDir))
        initLog += "- RMSD: " + auxRMSD + "\n"
        initLog += "- Timer: " + str(
            self.__timer.getTimeChronometer()) + "\n" + "\n"
        self.__log = initLog + self.__log

        'Data Log'
        IO.writeLog("iterations.log", self.__log, self.__fileDir)
        IO.writeLog("data.log", self.__dataLog, self.__fileDir)
        IO.writeHistoricLog(
            "historic.log",
            str(self.__scoreFx.getBestScore()) + ";" + auxRMSD + ";" +
            str(self.__bestLoop) + ";" + str(self.__loop), self.__fileDir)

        'Delete files'
        Methods.deleteTempFiles(self.__scoreFx.getLigandName(),
                                self.__moleculeName)
Example #4
0
    def generateScoring(self, protein, ligand, traceBest=True):

        ligand_p = rosetta.core.pose.Pose()
        rosetta.core.import_pose.pose_from_pdbstring(
            ligand_p, IO.getPbdStr(protein, ligand, self.__pdbStr))
        score = self.__scorefxn(ligand_p)

        'Best Values'
        if (traceBest):
            self.traceScoring(ligand, score)
        return score
Example #5
0
import copy

'************************** PDB FILES ***************************'

__MoleculeName = '1BV9'
__LigandName = 'XV6'
__pdbLigand = '1BV9_Flexible_2_RMSD_1.400_ligand.pdb'

'****************************************************************'

'Constants'
tempPath = os.path.join(ROOTPATH, 'temp')
pdbPath = os.path.join(ROOTPATH, 'originalPdb')

'Reads data'
newLigand = IO.readPDB(__pdbLigand, 'HETATM', pdbPath)
moleculeList = IO.readAllPDB(__MoleculeName + '.pdb', __LigandName, pdbPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

'Writes a new clean structure'
IO.writePDB("ligand.pdb", ligand, tempPath)
IO.writePDB("protein.pdb", protein, tempPath)

'Gets Connection Matrix'
connectMatrix = ligand.connectMatrix

'Init Scoring Function'
scoringFx = ScoringFunction.ScoringFunction()
scoringFx.defineLigandStructure("ligand.pdb", __LigandName, tempPath)
Example #6
0
__initTemperature = 1000
__minTemperature = 1
__alphaTemperature = 0.9
__innerLoop = 1

'Random Seed'
random.seed(2139738276)

'****************************************************************'

'Timer start'
timer = TimeManager()
timer.start()

'Reads data'
moleculeList = IO.readAllPDB(__testPDB, __LigandName)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

'Center Molecule'
originPoint = protein.findCenter()
protein.translate(
    [originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])
ligand.translate(
    [originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])

'Traslate search center point'
alterCenterPoint = [
    __searchCenterPoint[0] + (originPoint[0] * -1),
    __searchCenterPoint[1] + (originPoint[1] * -1),
    __searchCenterPoint[2] + (originPoint[2] * -1)
Example #7
0
__minTemperature = 1
__alphaTemperature = 0.9
__innerLoop = 1

'Random Seed'
random.seed(2139738276)


'****************************************************************'

'Timer start'
timer = TimeManager()
timer.start()

'Reads data'
moleculeList = IO.readAllPDB(__testPDB, __LigandName)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

'Center Molecule'
originPoint = protein.findCenter()
protein.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])
ligand.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])

'Traslate search center point'
alterCenterPoint = [__searchCenterPoint[0] + (originPoint[0]*-1),
                    __searchCenterPoint[1] + (originPoint[1]*-1),
                    __searchCenterPoint[2] + (originPoint[2]*-1)]

'Writes a new clean structure'
IO.writePDB("ligand.pdb", ligand, os.path.join(ROOTPATH,'temp'))
__MoleculeName = '2UPJ.pdb'
__LigandName = 'U02'

#__MoleculeName = '1BV9.pdb'
#__LigandName = 'XV6'

'****************************************************************'

'Constants'
moleculeName = __MoleculeName.replace(".pdb", "")
resultPath = os.path.join(ROOTPATH, 'results')
pdbPath = os.path.join(ROOTPATH, 'testPdb')
originalPath = os.path.join(ROOTPATH, 'originalPdb')

'Reads data'
moleculeList = IO.readAllPDB(__MoleculeName, __LigandName, originalPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

'Writes a new clean structure'
IO.writePDB(moleculeName + "_ligand.pdb", ligand, resultPath)
IO.writePDB(moleculeName + "_protein.pdb", protein, resultPath)
IO.writeAllPDB(moleculeName + "_clean.pdb", protein, ligand, resultPath, True)

'Print Center'
proteinCenter = protein.findCenter()
ligandCenter = ligand.findCenter()
print "Protein Center [ " + str(proteinCenter[0]) + ", " + str(
    proteinCenter[1]) + ", " + str(proteinCenter[2]) + " ]"
print "Ligand Center  [ " + str(ligandCenter[0]) + ", " + str(
    ligandCenter[1]) + ", " + str(ligandCenter[2]) + " ]"
Example #9
0
__SearchSpaceSize = 5

'*********************+*** Other Params *************************'

__onlyLigand = False
__dataLog = True

'****************************************************************'

'Constants'
resultPath = os.path.join(ROOTPATH, 'results')
tempPath = os.path.join(ROOTPATH, 'temp')
pdbPath = os.path.join(ROOTPATH, 'originalPdb')

'Reads data'
moleculeList = IO.readAllPDB(__MoleculeName + '.pdb', __LigandName, pdbPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])
ligandOri = copy.deepcopy(moleculeList[1])

'Center Molecule'
originPoint = protein.findCenter()
ligandPoint = ligand.findCenter()
#protein.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])
#ligand.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])
#ligandOri.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])

'Traslate search center point'
alterCenterPoint = [
    __SearchCenterPoint[0] + (originPoint[0] * -1),
    __SearchCenterPoint[1] + (originPoint[1] * -1),
Example #10
0
__MoleculeName = '2UPJ_Flexible_4_RMSD_1.300.pdb'
__LigandName = 'U02'

'****************************************************************'

ligandFile = 'ligand_' + __LigandName + '.pdb'
proteinFile = 'protein_' + __LigandName + '.pdb'
molFile = 'ligand_' + __LigandName + '.mol'

'Constants'
resultPath = os.path.join(ROOTPATH,'results')
pdbPath = os.path.join(ROOTPATH,'testPdb')
tempPath = os.path.join(ROOTPATH,'temp')
originalPath = os.path.join(ROOTPATH,'originalPdb')
molPath = os.path.join(ROOTPATH,'others')

moleculeList = IO.readAllPDB(__MoleculeName, __LigandName, originalPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

IO.writePDB(ligandFile, ligand, tempPath)
IO.writePDB(proteinFile, protein, tempPath)


'Creates mdl file'
os.system(BABEL_COM + ' -ipdb ' + os.path.join(tempPath, ligandFile) + ' -omdl ' + os.path.join(tempPath, molFile))

os.system(DELETE_COM + os.path.join(tempPath, ligandFile))
os.system(DELETE_COM + os.path.join(tempPath, proteinFile))

Example #11
0
#__LigandName = 'KNI'

__MoleculeName = '2UPJ.pdb'
__LigandName = 'U02'

#__MoleculeName = '1BV9.pdb'
#__LigandName = 'XV6'

'****************************************************************'

'Constants'
moleculeName = __MoleculeName.replace(".pdb", "")
resultPath = os.path.join(ROOTPATH,'results')
pdbPath = os.path.join(ROOTPATH,'testPdb')
originalPath = os.path.join(ROOTPATH,'originalPdb')

'Reads data'
moleculeList = IO.readAllPDB(__MoleculeName, __LigandName, originalPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

'Writes a new clean structure'
IO.writePDB(moleculeName + "_ligand.pdb", ligand, resultPath)
IO.writePDB(moleculeName + "_protein.pdb", protein, resultPath)
IO.writeAllPDB(moleculeName + "_clean.pdb", protein, ligand, resultPath, True)

'Print Center'
proteinCenter = protein.findCenter()
ligandCenter = ligand.findCenter()
print "Protein Center [ " + str(proteinCenter[0]) + ", " + str(proteinCenter[1]) + ", " + str(proteinCenter[2]) + " ]"
print "Ligand Center  [ " + str(ligandCenter[0]) + ", " + str(ligandCenter[1]) + ", " + str(ligandCenter[2]) + " ]"
Example #12
0
'************************** PDB FILES ***************************'

__MoleculeName = '1BV9'
__LigandName = 'XV6'
__pdbLigand = '1BV9_Flexible_2_RMSD_1.400_ligand.pdb'

'****************************************************************'


'Constants'
tempPath = os.path.join(ROOTPATH,'temp')
pdbPath = os.path.join(ROOTPATH,'originalPdb')

'Reads data'
newLigand = IO.readPDB(__pdbLigand, 'HETATM', pdbPath)
moleculeList = IO.readAllPDB(__MoleculeName + '.pdb', __LigandName, pdbPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

'Writes a new clean structure'
IO.writePDB("ligand.pdb", ligand, tempPath)
IO.writePDB("protein.pdb", protein, tempPath)

'Gets Connection Matrix'
connectMatrix = ligand.connectMatrix

'Init Scoring Function'
scoringFx = ScoringFunction.ScoringFunction()
scoringFx.defineLigandStructure("ligand.pdb", __LigandName, tempPath)
Example #13
0
'*********************+*** Other Params *************************'

__onlyLigand = False
__dataLog = True

'****************************************************************'


'Constants'
resultPath = os.path.join(ROOTPATH,'results')
tempPath = os.path.join(ROOTPATH,'temp')
pdbPath = os.path.join(ROOTPATH,'originalPdb')

'Reads data'
moleculeList = IO.readAllPDB(__MoleculeName + '.pdb', __LigandName, pdbPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])
ligandOri = copy.deepcopy(moleculeList[1])

'Center Molecule'
originPoint = protein.findCenter()
ligandPoint = ligand.findCenter()
#protein.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])
#ligand.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])
#ligandOri.translate([originPoint[0] * -1, originPoint[1] * -1, originPoint[2] * -1])

'Traslate search center point'
alterCenterPoint = [__SearchCenterPoint[0] + (originPoint[0]*-1),
                    __SearchCenterPoint[1] + (originPoint[1]*-1),
                    __SearchCenterPoint[2] + (originPoint[2]*-1)]
Example #14
0
__MoleculeName = '2UPJ_Flexible_4_RMSD_1.300.pdb'
__LigandName = 'U02'

'****************************************************************'

ligandFile = 'ligand_' + __LigandName + '.pdb'
proteinFile = 'protein_' + __LigandName + '.pdb'
molFile = 'ligand_' + __LigandName + '.mol'

'Constants'
resultPath = os.path.join(ROOTPATH, 'results')
pdbPath = os.path.join(ROOTPATH, 'testPdb')
tempPath = os.path.join(ROOTPATH, 'temp')
originalPath = os.path.join(ROOTPATH, 'originalPdb')
molPath = os.path.join(ROOTPATH, 'others')

moleculeList = IO.readAllPDB(__MoleculeName, __LigandName, originalPath)
protein = copy.deepcopy(moleculeList[0])
ligand = copy.deepcopy(moleculeList[1])

IO.writePDB(ligandFile, ligand, tempPath)
IO.writePDB(proteinFile, protein, tempPath)

'Creates mdl file'
os.system(BABEL_COM + ' -ipdb ' + os.path.join(tempPath, ligandFile) +
          ' -omdl ' + os.path.join(tempPath, molFile))

os.system(DELETE_COM + os.path.join(tempPath, ligandFile))
os.system(DELETE_COM + os.path.join(tempPath, proteinFile))
Example #15
0
 def getPoseFromPdbStr(self, protein, ligand):
     ligand_p = rosetta.core.pose.Pose()
     rosetta.core.import_pose.pose_from_pdbstring(
         ligand_p, IO.getPbdStr(protein, ligand, self.__pdbStr))
     return ligand_p