Ejemplo n.º 1
0
def annotateEntry(entry_code, bmrb_id, *extraArgList):
    'Return True on error'
    nTmessage(header)
    nTmessage(getStartMessage())

    expectedArgumentList = []
    expectedNumberOfArguments = len(expectedArgumentList)
    if len(extraArgList) != expectedNumberOfArguments:
        nTerror("Got arguments: " + repr(extraArgList))
        nTerror("Failed to get expected number of arguments: %d got %d" %
                (expectedNumberOfArguments, len(extraArgList)))
        nTerror("Expected arguments: %s" % expectedArgumentList)
        return True
#    entry_code, city = entryCodePlusCity.split('_')

# Adjust the parameters below
    isInteractive = False
    checkOrgProject = False
    doSwapCheck = False
    doSaveProject = True
    doExport = True

    minimalPrompts = True
    verbose = True
    allowPopups = False

    if isInteractive:
        allowPopups = True
        minimalPrompts = False
#        verbose = True
    else:
        pass
#        minimalPrompts = True
#        verbose = False

    print 'entry_code                                                                                    ', entry_code
    print 'bmrb_id                                                                                       ', bmrb_id
    print 'allowPopups                                                                                   ', allowPopups
    print 'isInteractive                                                                                 ', isInteractive
    print 'minimalPrompts                                                                                ', minimalPrompts
    print 'verbose                                                                                       ', verbose
    print 'checkOrgProject                                                                               ', checkOrgProject
    print 'doSwapCheck                                                                                   ', doSwapCheck
    print 'doSaveProject                                                                                 ', doSaveProject
    print 'doExport                                                                                      ', doExport

    guiRoot = None
    if allowPopups:
        guiRoot = Tkinter.Tk()

    ch23 = entry_code[1:3]
    dataOrgEntryDir = os.path.join(results_dir, 'recoordSync', entry_code)
    ccpnFile = os.path.join(dataOrgEntryDir, entry_code + ".tgz")
    if not os.path.exists(ccpnFile):
        nTerror("Input file not found: %s" % ccpnFile)
        return True
    nTdebug("Looking at %s" % entry_code)
    #                continue # TODO disable premature stop.

    bmrb_code = 'bmr' + bmrb_id

    digits12 = "%02d" % (bmrb_id % 100)
    inputStarDir = os.path.join(bmrbDir, digits12)
    if not os.path.exists(inputStarDir):
        nTerror("Input star dir not found: %s" % inputStarDir)
        return True
    inputStarFile = os.path.join(inputStarDir, '%s.str' % bmrb_code)
    if not os.path.exists(inputStarFile):
        nTerror("inputStarFile not found: %s" % inputStarFile)
        return True

    dataDividedXDir = os.path.join(nrgPlusDir, ch23)
    entryDir = os.path.join(dataDividedXDir, entry_code)
    outputNijmegenDir = os.path.join(entryDir, 'Nijmegen')
    if not os.path.exists(outputNijmegenDir):
        mkdirs(outputNijmegenDir)
    os.chdir(outputNijmegenDir)

    presets = getDeepByKeysOrDefault(presetDict, {}, bmrb_code)
    if presets:
        nTmessage("In annotateLoop using preset values...")
        nTdebug(str(presets))

    if os.path.exists(entry_code):
        nTmessage("Removing previous directory: %s" % entry_code)
        rmtree(entry_code)
    do_cmd("tar -xzf " + ccpnFile)
    if os.path.exists('linkNmrStarData'):
        nTmessage("Renaming standard directory linkNmrStarData to entry: %s" %
                  entry_code)
        os.rename('linkNmrStarData', entry_code)

    if checkOrgProject:
        # By reading the ccpn tgz into cing it is also untarred/tested.
        project = Project.open(entry_code, status='new')
        if not project.initCcpn(ccpnFolder=ccpnFile, modelCount=1):
            nTerror("Failed check of original project")
            return True
        project.removeFromDisk()
        project.close(save=False)

    ccpnProject = loadProject(entry_code)
    if not ccpnProject:
        nTerror("Failed to read project: %s" % entry_code)
        return True

#            nmrProject = ccpnProject.currentNmrProject
#            ccpnMolSystem = ccpnProject.findFirstMolSystem()
#            nTmessage('found ccpnMolSystem: %s' % ccpnMolSystem)
#    print 'status: %s' % ccpnMolSystem.setCode(projectName) # impossible; reported to ccpn team.

    importStarChemicalShifts(ccpnProject,
                             inputStarDir,
                             guiRoot,
                             allowPopups=allowPopups,
                             minimalPrompts=minimalPrompts,
                             verbose=verbose,
                             **presets)

    if doSwapCheck:
        #        constraintsHandler = ConstraintsHandler()
        nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore()
        structureEnsemble = ccpnProject.findFirstStructureEnsemble()
        numSwapCheckRuns = 3
        if nmrConstraintStore:
            if structureEnsemble:
                swapCheck(nmrConstraintStore, structureEnsemble,
                          numSwapCheckRuns)
            else:
                nTmessage(
                    "Failed to find structureEnsemble; skipping swapCheck")
        else:
            nTmessage("Failed to find nmrConstraintStore; skipping swapCheck")
#        constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)

    if doSaveProject:
        #        nTmessage('Checking validity and saving to new path')
        nTmessage('Saving to new path')
        #        checkValid=True,
        saveProject(ccpnProject, newPath=entry_code, removeExisting=True)
    if doExport:
        tarPath = os.path.join(entryDir, entry_code + ".tgz")
        if os.path.exists(tarPath):
            nTmessage("Overwriting: " + tarPath)
        myTar = tarfile.open(tarPath, mode='w:gz')  # overwrites
        myTar.add(entry_code)
        myTar.close()
    if guiRoot:
        guiRoot.destroy()
Ejemplo n.º 2
0
def annotateEntry(entryCodeNew, *extraArgList):
    nTmessage(header)
    nTmessage(getStartMessage())

    expectedArgumentList = []
    expectedNumberOfArguments = len(expectedArgumentList)
    if len(extraArgList) != expectedNumberOfArguments:
        nTerror("Got arguments: " + repr(extraArgList))
        nTerror("Failed to get expected number of arguments: %d got %d" % (
            expectedNumberOfArguments, len(extraArgList)))
        nTerror("Expected arguments: %s" % expectedArgumentList)
        return True
#    entryCode, city = entryCodePlusCity.split('_')

    # Adjust the parameters below
    isInteractive = False
    sourceIsOrgProject = True
    checkOrgProject = False
    replaceCoordinates = True # From all *.pdb files in inputDir.
    replaceRestraints = True
    doSwapCheck = True
    doSaveProject = True
    doExport = True

    minimalPrompts = True
    verbose = True

    if isInteractive:
        allowPopups = True
        minimalPrompts = False
#        verbose = True
    else:
        allowPopups = False
#        minimalPrompts = True
#        verbose = False

    print 'allowPopups                                                                                   ', allowPopups
    print 'isInteractive                                                                                 ', isInteractive
    print 'minimalPrompts                                                                                ', minimalPrompts
    print 'verbose                                                                                       ', verbose
    print 'sourceIsOrgProject                      (or new CCPN file)                                    ', sourceIsOrgProject
    print 'checkOrgProject                                                                               ', checkOrgProject
    print 'replaceCoordinates                                                                            ', replaceCoordinates
    print 'replaceRestraints                                                                             ', replaceRestraints
    print 'doSwapCheck                                                                                   ', doSwapCheck
    print 'doSaveProject                                                                                 ', doSaveProject
    print 'doExport                                                                                      ', doExport

    guiRoot = None
    if allowPopups:
        guiRoot = Tkinter.Tk()

    entryCode,city = mapEntrycodeNew2EntrycodeAndCity[entryCodeNew]
    ch23 = entryCode[1:3]
    entryCodeOrg = entryCode + 'Org'
    dataOrgEntryDir = os.path.join(dataDir, ch23, entryCodeOrg)
    ccpnFile = os.path.join(dataOrgEntryDir, entryCodeOrg + ".tgz")
#    entryCodeNew = entryCode + city
    programId = getDeepByKeys(programHoH, entryCode, city)
    if not (city == 'Test' or programId):
#                nTdebug("Skipping %s" % entryCodeNew)
        nTerror("Neither City is 'Test' or programId given")
        return
    else:
        nTdebug("Looking at %s" % entryCodeNew)
#                continue # TODO disable premature stop.


    dataDividedXDir = os.path.join(dataDir, ch23)
    entryDir = os.path.join(dataDividedXDir, entryCodeNew)
    inputAuthorDir = os.path.join(entryDir, 'Author')
    outputNijmegenDir = os.path.join(entryDir, 'Nijmegen')

    if not os.path.exists(inputAuthorDir):
        mkdirs(inputAuthorDir)
    if not os.path.exists(outputNijmegenDir):
        mkdirs(outputNijmegenDir)

    os.chdir(outputNijmegenDir)

    presets = getDeepByKeysOrDefault(presetDict, {}, entryCodeNew)
    if presets:
        nTmessage("In annotateLoop using preset values...")
    # end if

    if sourceIsOrgProject:
        if os.path.exists(entryCodeOrg):
            nTmessage("Removing previous Org directory: %s" % entryCodeOrg)
            rmtree(entryCodeOrg)
        do_cmd("tar -xzf " + ccpnFile)
        if os.path.exists(entryCodeNew):
            nTmessage("Removing previous directory: %s" % entryCodeNew)
            rmtree(entryCodeNew)
        copytree(entryCodeOrg, entryCodeNew)

    if checkOrgProject:
        # By reading the ccpn tgz into cing it is also untarred/tested.
        project = Project.open(entryCodeOrg, status='new')
        if not project.initCcpn(ccpnFolder=ccpnFile, modelCount=1):
            nTerror("Failed check of original project")
            return
        project.removeFromDisk()
        project.close(save=False)

    ccpnProject = loadProject(entryCodeNew)
    if not ccpnProject:
        nTerror("Failed to read project: %s" % entryCodeNew)
        return

#            nmrProject = ccpnProject.currentNmrProject
#            ccpnMolSystem = ccpnProject.findFirstMolSystem()
#            nTmessage('found ccpnMolSystem: %s' % ccpnMolSystem)
#    print 'status: %s' % ccpnMolSystem.setCode(projectName) # impossible; reported to ccpn team.

    if replaceCoordinates or replaceRestraints:
        if programId == CYANA:
            importCyanaCoorAndRes(ccpnProject, inputAuthorDir, guiRoot,
                replaceCoordinates=replaceCoordinates, replaceRestraints=replaceRestraints, 
                allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets)
        elif programId == XPLOR:
            importXplorCoorAndRes(ccpnProject, inputAuthorDir, guiRoot,
                replaceCoordinates=replaceCoordinates, replaceRestraints=replaceRestraints, 
                allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets)
        elif programId == PDB:
            importPseudoPdb(ccpnProject, inputAuthorDir, guiRoot,
                allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets)
        else:
            nTerror("Failed to doImportCoordinatesAndRestraints because action for program Id not coded for: %s" % programId)
            nTerror("Skipping entry")
            return

    if doSwapCheck:
#        constraintsHandler = ConstraintsHandler()
        nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore()
        structureEnsemble = ccpnProject.findFirstStructureEnsemble()
        numSwapCheckRuns = 3
        if nmrConstraintStore:
            if structureEnsemble:
                swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)
            else:
                nTmessage("Failed to find structureEnsemble; skipping swapCheck")
        else:
            nTmessage("Failed to find nmrConstraintStore; skipping swapCheck")
#        constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)

    if doSaveProject:
#        nTmessage('Checking validity and saving to new path')
        nTmessage('Saving to new path: %s' % entryCodeNew)
#        checkValid=True,
        saveProject(ccpnProject, newPath=entryCodeNew, removeExisting=True)
    if doExport:
        tarPath = os.path.join(entryDir, entryCodeNew + ".tgz")
        if os.path.exists(tarPath):
            nTmessage("Overwriting: " + tarPath)
        myTar = tarfile.open(tarPath, mode='w:gz') # overwrites
        myTar.add(entryCodeNew)
        myTar.close()
    if guiRoot:
        guiRoot.destroy()
Ejemplo n.º 3
0
def annotateEntry(entry_code, bmrb_id, *extraArgList):
    'Return True on error'
    nTmessage(header)
    nTmessage(getStartMessage())

    expectedArgumentList = []
    expectedNumberOfArguments = len(expectedArgumentList)
    if len(extraArgList) != expectedNumberOfArguments:
        nTerror("Got arguments: " + repr(extraArgList))
        nTerror("Failed to get expected number of arguments: %d got %d" % (
            expectedNumberOfArguments, len(extraArgList)))
        nTerror("Expected arguments: %s" % expectedArgumentList)
        return True
#    entry_code, city = entryCodePlusCity.split('_')

    # Adjust the parameters below
    isInteractive = False
    checkOrgProject = False
    doSwapCheck = False
    doSaveProject = True
    doExport = True

    minimalPrompts = True
    verbose = True
    allowPopups = False

    if isInteractive:
        allowPopups = True
        minimalPrompts = False
#        verbose = True
    else:
        pass
#        minimalPrompts = True
#        verbose = False

    print 'entry_code                                                                                    ', entry_code
    print 'bmrb_id                                                                                       ', bmrb_id
    print 'allowPopups                                                                                   ', allowPopups
    print 'isInteractive                                                                                 ', isInteractive
    print 'minimalPrompts                                                                                ', minimalPrompts
    print 'verbose                                                                                       ', verbose
    print 'checkOrgProject                                                                               ', checkOrgProject
    print 'doSwapCheck                                                                                   ', doSwapCheck
    print 'doSaveProject                                                                                 ', doSaveProject
    print 'doExport                                                                                      ', doExport

    guiRoot = None
    if allowPopups:
        guiRoot = Tkinter.Tk()

    ch23 = entry_code[1:3]
    dataOrgEntryDir = os.path.join(results_dir, 'recoordSync', entry_code)
    ccpnFile = os.path.join(dataOrgEntryDir, entry_code + ".tgz")
    if not os.path.exists(ccpnFile):
        nTerror("Input file not found: %s" % ccpnFile)
        return True
    nTdebug("Looking at %s" % entry_code)
#                continue # TODO disable premature stop.

    bmrb_code = 'bmr'+bmrb_id

    digits12 ="%02d" % ( bmrb_id % 100 )
    inputStarDir = os.path.join(bmrbDir, digits12)
    if not os.path.exists(inputStarDir):
        nTerror("Input star dir not found: %s" % inputStarDir)
        return True
    inputStarFile = os.path.join(inputStarDir, '%s.str'%bmrb_code)
    if not os.path.exists(inputStarFile):
        nTerror("inputStarFile not found: %s" % inputStarFile)
        return True

    dataDividedXDir = os.path.join(nrgPlusDir, ch23)
    entryDir = os.path.join(dataDividedXDir, entry_code)
    outputNijmegenDir = os.path.join(entryDir, 'Nijmegen')
    if not os.path.exists(outputNijmegenDir):
        mkdirs(outputNijmegenDir)
    os.chdir(outputNijmegenDir)

    presets = getDeepByKeysOrDefault(presetDict, {}, bmrb_code)
    if presets:
        nTmessage("In annotateLoop using preset values...")
        nTdebug(str(presets))

    if os.path.exists(entry_code):
        nTmessage("Removing previous directory: %s" % entry_code)
        rmtree(entry_code)
    do_cmd("tar -xzf " + ccpnFile)
    if os.path.exists('linkNmrStarData'):
        nTmessage("Renaming standard directory linkNmrStarData to entry: %s" % entry_code)
        os.rename('linkNmrStarData', entry_code)

    if checkOrgProject:
        # By reading the ccpn tgz into cing it is also untarred/tested.
        project = Project.open(entry_code, status='new')
        if not project.initCcpn(ccpnFolder=ccpnFile, modelCount=1):
            nTerror("Failed check of original project")
            return True
        project.removeFromDisk()
        project.close(save=False)

    ccpnProject = loadProject(entry_code)
    if not ccpnProject:
        nTerror("Failed to read project: %s" % entry_code)
        return True

#            nmrProject = ccpnProject.currentNmrProject
#            ccpnMolSystem = ccpnProject.findFirstMolSystem()
#            nTmessage('found ccpnMolSystem: %s' % ccpnMolSystem)
#    print 'status: %s' % ccpnMolSystem.setCode(projectName) # impossible; reported to ccpn team.

    importStarChemicalShifts(ccpnProject, inputStarDir, guiRoot, allowPopups=allowPopups, minimalPrompts=minimalPrompts, 
                             verbose=verbose, **presets)

    if doSwapCheck:
#        constraintsHandler = ConstraintsHandler()
        nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore()
        structureEnsemble = ccpnProject.findFirstStructureEnsemble()
        numSwapCheckRuns = 3
        if nmrConstraintStore:
            if structureEnsemble:
                swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)
            else:
                nTmessage("Failed to find structureEnsemble; skipping swapCheck")
        else:
            nTmessage("Failed to find nmrConstraintStore; skipping swapCheck")
#        constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)

    if doSaveProject:
#        nTmessage('Checking validity and saving to new path')
        nTmessage('Saving to new path')
#        checkValid=True,
        saveProject(ccpnProject, newPath=entry_code, removeExisting=True)
    if doExport:
        tarPath = os.path.join(entryDir, entry_code + ".tgz")
        if os.path.exists(tarPath):
            nTmessage("Overwriting: " + tarPath)
        myTar = tarfile.open(tarPath, mode='w:gz') # overwrites
        myTar.add(entry_code)
        myTar.close()
    if guiRoot:
        guiRoot.destroy()
Ejemplo n.º 4
0
    def test_ccpn(self):
        #        cing.verbosity = verbosityDebug
        #        if you have a local copy you can use it; make sure to adjust the path setting below.
        fastestTest = True  # DEFAULT: True. Not passed to the validate routine in order to customize checks for speed.

        modelCount = 99  # DEFAULT: 99
        redoFromCingProject = False  # DEFAULT: False
        htmlOnly = False  # DEFAULT: False # default is False but enable it for faster runs without some actual data.
        doWhatif = True  # DEFAULT: True # disables whatif actual run
        doProcheck = True  # DEFAULT: True
        doWattos = True  # DEFAULT: True
        doQueeny = True  # DEFAULT: True
        doTalos = True  # DEFAULT: True
        filterVasco = True  # DEFAULT: True
        filterTopViolations = True  # DEFAULT: True
        useNrgArchive = False  # DEFAULT: False
        ranges = CV_STR  # DEFAULT: CV_STR
        #        ranges='173-177'
        #        ranges='6-13,29-45' # 1bus

        doSwapCheck = False
        doRestoreCheck = False
        doStoreCheck = False  # DEFAULT: False Requires sqlAlchemy
        doSave = not redoFromCingProject  # DEFAULT: False Requires sqlAlchemy

        if fastestTest:
            modelCount = 2  # DEFAULT 2
            #            redoFromCingProject = False
            htmlOnly = True  # DEFAULT: True
            doWhatif = False  # DEFAULT: False
            doProcheck = False  # DEFAULT: False
            doWattos = False  # DEFAULT: False
            doQueeny = False  # DEFAULT: False
            doTalos = False  # DEFAULT: False
            filterVasco = False  # DEFAULT: False
            doRestoreCheck = False  # DEFAULT: False
            doStoreCheck = False  # DEFAULT: False
        if redoFromCingProject:
            useNrgArchive = False
            doWhatif = False
            doProcheck = False
            doWattos = False
            doTalos = False
        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)
        for i, entryId in enumerate(AllChecks.entryList):

            if i:
                nTmessage('\n\n')
            if redoFromCingProject:
                project = Project.open(entryId, status='old')
            else:
                project = Project.open(entryId, status='new')
                self.assertTrue(project, 'Failed opening project: ' + entryId)

                if useNrgArchive:  # default is False
                    #                inputArchiveDir = os.path.join('/Library/WebServer/Documents/NRG-CING/recoordSync', entryId)
                    # Mounted from nmr.cmbi.ru.nl
                    #                inputArchiveDir = os.path.join('/Volumes/tria1/Library/WebServer/Documents/NRG-CING/recoordSync', entryId)
                    inputArchiveDir = os.path.join(
                        '/Users/jd/ccpn_tmp/data/recoord', entryId)
                else:
                    inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

                ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
                if not os.path.exists(ccpnFile):
                    ccpnFile = os.path.join(inputArchiveDir,
                                            entryId + ".tar.gz")
                    if not os.path.exists(ccpnFile):
                        self.fail("Neither %s or the .tgz exist" % ccpnFile)

                if doSwapCheck:  # Need to start with ccpn without loading into CING api yet.
                    if os.path.exists(entryId):
                        nTmessage("Removing previous directory: %s" % entryId)
                        rmtree(entryId)
                    do_cmd("tar -xzf " +
                           ccpnFile)  # will extract to local dir.
                    if os.path.exists('linkNmrStarData'):
                        nTmessage(
                            "Renaming standard directory linkNmrStarData to entry: %s"
                            % entryId)
                        os.rename('linkNmrStarData', entryId)

                    ccpnProject = loadProject(entryId)
                    if not ccpnProject:
                        self.fail("Failed to read project: %s" % entryId)
            #        constraintsHandler = ConstraintsHandler()
                    nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore(
                    )
                    structureEnsemble = ccpnProject.findFirstStructureEnsemble(
                    )
                    numSwapCheckRuns = 2
                    if nmrConstraintStore:
                        if structureEnsemble:
                            swapCheck(nmrConstraintStore, structureEnsemble,
                                      numSwapCheckRuns)
                        else:
                            nTmessage(
                                "Failed to find structureEnsemble; skipping swapCheck"
                            )
                    else:
                        nTmessage(
                            "Failed to find nmrConstraintStore; skipping swapCheck"
                        )
            #        constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)
                    nTmessage('Saving to new path')
                    #        checkValid=True,
                    saveProject(ccpnProject,
                                newPath=entryId,
                                removeExisting=True)
                    ccpnFile = entryId  # set to local dir now.
                # end if doSwapCheck
                self.assertTrue(
                    project.initCcpn(ccpnFolder=ccpnFile,
                                     modelCount=modelCount))
#                if doSave:
#                    self.assertTrue(project.save())

            if False:
                ranges = "173-183"
#                residueOfInterest = range(171,174)
#                for residue in project.molecule.A.allResidues():
#                    if residue.resNum not in residueOfInterest:
#    #                    nTmessage("Removing residue of no interest")
#                        project.molecule.A.removeResidue(residue)
            if False:
                ccpnProject = project.ccpn
                printSequenceFromCcpnProject(ccpnProject)

            if True:
                self.assertFalse(project.molecule.setRanges(ranges))
                nTdebug('In test_ccpn.py: ranges: %s' %
                        str(project.molecule.ranges))
                project.molecule.rangesToMmCifRanges(ranges)

            if True:
                self.assertFalse(
                    project.validate(
                        htmlOnly=htmlOnly,
                        ranges=ranges,
                        #                                              fastestTest=fastestTest, # disabled
                        doProcheck=doProcheck,
                        doWhatif=doWhatif,
                        doWattos=doWattos,
                        doQueeny=doQueeny,
                        doTalos=doTalos,
                        filterVasco=filterVasco,
                        filterTopViolations=filterTopViolations))
                if doWattos and False:
                    mol = project.molecule
                    completenessMol = mol.getDeepByKeys(
                        WATTOS_STR, COMPLCHK_STR, VALUE_LIST_STR)
                    nTdebug("completenessMol: %s" % completenessMol)
                    for res in mol.allResidues():
                        completenessRes = res.getDeepByKeys(
                            WATTOS_STR, COMPLCHK_STR, VALUE_LIST_STR)
                        nTdebug("%s: %s" % (res, completenessRes))
                    # end for
                # end if
                color = project.molecule.getRogColor()
                nTdebug("The color of this molecule is: %s" % color)
                self.assertFalse(color == COLOR_RED)  # ;-)
            # end if
#            self.assertTrue(project.exportValidation2ccpn())
#            self.assertFalse(project.removeCcpnReferences())
# Do not leave the old CCPN directory laying around since it might get added to by another test.
#            if os.path.exists(entryId):
#                self.assertFalse(shutil.rmtree(entryId))

            if False:
                self.assertTrue(project.save())
                self.assertTrue(project.saveCcpn(entryId))

            if doRestoreCheck:
                del project
                project = Project.open(entryId, status='old')
                self.assertTrue(project,
                                'Failed reopening project: ' + entryId)
            if doStoreCheck:
                #                # Does require below import which is used here to trigger import warning in case it's not installed.
                # pylint: disable=W0612
                from cing.PluginCode.sqlAlchemy import CsqlAlchemy  #@UnusedImport # pylint: disable=W0404
                if doStoreCING2db(entryId, ARCHIVE_NRG_ID, project=project):
                    nTerror(
                        "Failed to store CING project's data to DB but continuing."
                    )
            if doSave:
                self.assertTrue(project.save())
Ejemplo n.º 5
0
    def test_ccpn(self):
#        cing.verbosity = verbosityDebug
#        if you have a local copy you can use it; make sure to adjust the path setting below.
        fastestTest = True             # DEFAULT: True. Not passed to the validate routine in order to customize checks for speed.

        modelCount=99                  # DEFAULT: 99 
        redoFromCingProject = False    # DEFAULT: False 
        htmlOnly = False               # DEFAULT: False # default is False but enable it for faster runs without some actual data.
        doWhatif = True                # DEFAULT: True # disables whatif actual run
        doProcheck = True              # DEFAULT: True 
        doWattos = True                # DEFAULT: True 
        doQueeny = True                # DEFAULT: True 
        doTalos = True                 # DEFAULT: True 
        filterVasco = True             # DEFAULT: True 
        filterTopViolations = True     # DEFAULT: True 
        useNrgArchive = False          # DEFAULT: False 
        ranges = CV_STR                # DEFAULT: CV_STR 
#        ranges='173-177'
#        ranges='6-13,29-45' # 1bus

        doSwapCheck = False
        doRestoreCheck = False
        doStoreCheck = False # DEFAULT: False Requires sqlAlchemy
        doSave = not redoFromCingProject  # DEFAULT: False Requires sqlAlchemy

        if fastestTest:
            modelCount=2 # DEFAULT 2
#            redoFromCingProject = False
            htmlOnly = True            # DEFAULT: True
            doWhatif = False           # DEFAULT: False
            doProcheck = False         # DEFAULT: False
            doWattos = False           # DEFAULT: False
            doQueeny = False           # DEFAULT: False
            doTalos = False            # DEFAULT: False
            filterVasco = False        # DEFAULT: False
            doRestoreCheck = False     # DEFAULT: False
            doStoreCheck = False       # DEFAULT: False
        if redoFromCingProject:
            useNrgArchive = False
            doWhatif = False
            doProcheck = False
            doWattos = False
            doTalos = False
        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)
        for i,entryId in enumerate(AllChecks.entryList):

            if i:
                nTmessage('\n\n')
            if redoFromCingProject:
                project = Project.open(entryId, status = 'old')
            else:
                project = Project.open(entryId, status = 'new')
                self.assertTrue(project, 'Failed opening project: ' + entryId)

                if useNrgArchive: # default is False
    #                inputArchiveDir = os.path.join('/Library/WebServer/Documents/NRG-CING/recoordSync', entryId)
                    # Mounted from nmr.cmbi.ru.nl
    #                inputArchiveDir = os.path.join('/Volumes/tria1/Library/WebServer/Documents/NRG-CING/recoordSync', entryId)
                    inputArchiveDir = os.path.join('/Users/jd/ccpn_tmp/data/recoord', entryId)
                else:
                    inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

                ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
                if not os.path.exists(ccpnFile):
                    ccpnFile = os.path.join(inputArchiveDir, entryId + ".tar.gz")
                    if not os.path.exists(ccpnFile):
                        self.fail("Neither %s or the .tgz exist" % ccpnFile)

                if doSwapCheck: # Need to start with ccpn without loading into CING api yet.
                    if os.path.exists(entryId):
                        nTmessage("Removing previous directory: %s" % entryId)
                        rmtree(entryId)
                    do_cmd("tar -xzf " + ccpnFile) # will extract to local dir.
                    if os.path.exists('linkNmrStarData'):
                        nTmessage("Renaming standard directory linkNmrStarData to entry: %s" % entryId)
                        os.rename('linkNmrStarData', entryId)

                    ccpnProject = loadProject(entryId)
                    if not ccpnProject:
                        self.fail("Failed to read project: %s" % entryId)
            #        constraintsHandler = ConstraintsHandler()
                    nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore()
                    structureEnsemble = ccpnProject.findFirstStructureEnsemble()
                    numSwapCheckRuns = 2
                    if nmrConstraintStore:
                        if structureEnsemble:
                            swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)
                        else:
                            nTmessage("Failed to find structureEnsemble; skipping swapCheck")
                    else:
                        nTmessage("Failed to find nmrConstraintStore; skipping swapCheck")
            #        constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns)
                    nTmessage('Saving to new path')
            #        checkValid=True,
                    saveProject(ccpnProject, newPath=entryId, removeExisting=True)
                    ccpnFile = entryId # set to local dir now.
                # end if doSwapCheck
                self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile, modelCount=modelCount))
#                if doSave:
#                    self.assertTrue(project.save())

            if False:
                ranges = "173-183"
#                residueOfInterest = range(171,174)
#                for residue in project.molecule.A.allResidues():
#                    if residue.resNum not in residueOfInterest:
#    #                    nTmessage("Removing residue of no interest")
#                        project.molecule.A.removeResidue(residue)
            if False:
                ccpnProject = project.ccpn
                printSequenceFromCcpnProject(ccpnProject)

            if True:
                self.assertFalse(project.molecule.setRanges(ranges))
                nTdebug('In test_ccpn.py: ranges: %s' % str(project.molecule.ranges))
                project.molecule.rangesToMmCifRanges(ranges)

            if True:
                self.assertFalse(project.validate(htmlOnly = htmlOnly,
                                              ranges=ranges,
#                                              fastestTest=fastestTest, # disabled
                                              doProcheck = doProcheck,
                                              doWhatif = doWhatif,
                                              doWattos=doWattos,
                                              doQueeny = doQueeny,
                                              doTalos=doTalos,
                                              filterVasco=filterVasco,
                                              filterTopViolations = filterTopViolations
                                               ))
                if doWattos and False:
                    mol = project.molecule
                    completenessMol = mol.getDeepByKeys( WATTOS_STR, COMPLCHK_STR, VALUE_LIST_STR)
                    nTdebug("completenessMol: %s" % completenessMol)
                    for res in mol.allResidues():
                        completenessRes = res.getDeepByKeys( WATTOS_STR, COMPLCHK_STR, VALUE_LIST_STR)
                        nTdebug("%s: %s" % (res, completenessRes))
                    # end for
                # end if
                color = project.molecule.getRogColor()
                nTdebug("The color of this molecule is: %s" % color)
                self.assertFalse( color == COLOR_RED ) # ;-)
            # end if
#            self.assertTrue(project.exportValidation2ccpn())
#            self.assertFalse(project.removeCcpnReferences())
            # Do not leave the old CCPN directory laying around since it might get added to by another test.
#            if os.path.exists(entryId):
#                self.assertFalse(shutil.rmtree(entryId))

            if False:
                self.assertTrue(project.save())
                self.assertTrue(project.saveCcpn(entryId))

            if doRestoreCheck:
                del project
                project = Project.open(entryId, status = 'old')
                self.assertTrue(project, 'Failed reopening project: ' + entryId)
            if doStoreCheck:
#                # Does require below import which is used here to trigger import warning in case it's not installed.
                # pylint: disable=W0612
                from cing.PluginCode.sqlAlchemy import CsqlAlchemy #@UnusedImport # pylint: disable=W0404
                if doStoreCING2db( entryId, ARCHIVE_NRG_ID, project=project):
                    nTerror("Failed to store CING project's data to DB but continuing.")
            if doSave:
                self.assertTrue(project.save())