Esempio n. 1
0
    def test_cyana2cing(self):
#        SETUP FIRST
        projectId = "1pdb"
        cyanaDirectory = os.path.join( cingDirTestsData, "cyana", projectId )
        self.assertTrue( os.path.exists( cyanaDirectory) and os.path.isdir(cyanaDirectory ) )

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        projectRootPath = os.path.join( cingDirTmp, projectId )
        projectRoot = Project.rootPath( projectRootPath )[0] # xeasy_project.cing in /tmp
        if os.path.exists( projectRoot ):
            nTwarning('Output directory "%s" already exists. It will now be removed.' % projectRoot )
            self.failIf( shutil.rmtree(projectRoot), "Failed to remove old project directory." )

        project = Project.open(projectRootPath, 'new')
        project.cyana2cing( #project=project,
                            cyanaDirectory=cyanaDirectory,
                            uplFiles  = [projectId],
                            acoFiles  = [projectId,"talos"],
                            pdbFile   = projectId,
                            nmodels   = 2,
                            copy2sources = True
        )

        if not project:
            nTwarning("No project generated. Aborting further execution.")
            sys.exit(0)
        project.save()
Esempio n. 2
0
    def test_AddResidue_Standard(self):
        entryId = 'test'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')

        mol = Molecule('test')
        project.appendMolecule(mol)
        c = mol.addChain('A')
        r1 = c.addResidue('ALA', 1, Nterminal = True)
        if r1:
            r1.addAllAtoms()
        r2 = c.addResidue('VAL', 2)
        if r2:
            r2.addAllAtoms()
        r2 = c.addResidue('PHE', 3)
        if r2:
            r2.addAllAtoms()
        r2 = c.addResidue('ARG', 4)
        if r2:
            r2.addAllAtoms()
        r3 = c.addResidue('GLU', 5, Cterminal = True)
        if r3:
            r3.addAllAtoms()

        mol.updateAll()

        nTmessage( mol.format() )
Esempio n. 3
0
    def testPdbFile(self):
        nTwarning("This test case will take about 5 (+3 for 1v0e) minutes and is recommended to be done before major releases.")
    #        entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
    #        entryId = "1brv" # Small much studied PDB NMR entry
    #        entryId = "2hgh_1model"
#        entryList = "1kr8".split()
#        entryList = "1otz".split() # 61 chains of which one is ' '
#        entryList = "1v0e".split()
#        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 1otz 2hgh 2k0e".split()
        entryList = "1a4d 1ai0 1brv 1bus 1hue 1iv6 1kr8".split()
        for entryId in entryList:

            pdbDirectory = os.path.join(cingDirTestsData,"pdb", entryId)
            pdbFileName = "pdb"+entryId+".ent"
            pdbFilePath = os.path.join( pdbDirectory, pdbFileName)

            cingDirTmpTest = os.path.join( cingDirTmp, 'test2_pdb' )
            mkdirs( cingDirTmpTest )
            os.chdir(cingDirTmpTest)
            # does it matter to import it just now?
            project = Project( entryId )
            self.failIf( project.removeFromDisk())
            project = Project.open( entryId, status='new' )
            self.assertTrue( project.initPDB( pdbFile=pdbFilePath, convention=IUPAC, allowNonStandardResidue=True ))
            self.assertTrue( project.save() )
Esempio n. 4
0
def printSequenceFromPdbFile(fn):
    verbosityOriginal = cing.verbosity
    cing.verbosity = cing.verbosityError
    entryId = 'getSequenceFromPdbFile'
    project = Project(entryId)
    project.removeFromDisk()
    project = Project.open(entryId, status='new')
    project.initPDB(pdbFile=fn, convention=IUPAC)
    fastaString = ''
    for res in project.molecule.allResidues():
        # db doesn't always exist.
        fastaString += getDeepByKeysOrDefault(res, defaultPrintChainCode, 'db',
                                              'shortName')
    cing.verbosity = verbosityOriginal
    nTmessage("Sequence from PDB file:")
    nTmessage(fastaString)

    for res in project.molecule.allResidues():
        nTmessageNoEOL(res.shortName)
    nTmessage('')
    cing.verbosity = cing.verbosityError

    project.removeFromDisk()
    del project
    cing.verbosity = verbosityOriginal
Esempio n. 5
0
    def _test_Yasara(self):
        'Test is incomplete; do NOT use.'
        entryId = "testYasara"
        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)
        project = Project( entryId )
#            project = Project.open( entryId, status='old' )
        project.yasaraShell()
        yasara.Exit() # FAILS to ext really.
Esempio n. 6
0
 def _test_Yasara(self):
     'Test is incomplete; do NOT use.'
     entryId = "testYasara"
     cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
     mkdirs(cingDirTmpTest)
     self.failIf(os.chdir(cingDirTmpTest),
                 msg="Failed to change to test directory for files: " +
                 cingDirTmpTest)
     project = Project(entryId)
     #            project = Project.open( entryId, status='old' )
     project.yasaraShell()
     yasara.Exit()  # FAILS to ext really.
Esempio n. 7
0
    def test_Procheck(self):
        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        runAqua = True
        showProcheckResults = False
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
        entryId = "1bus"
        #        entryId = "1brv_1model" # Small much studied PDB NMR entry
        ranges = None

        if entryId.startswith("1brv"):
            ranges = "173-186"

        if entryId.startswith("1ai0"):
            ranges = "2-20"

        if entryId == "2hgh":
            # in the case of 2hgh this is not a problem because the residue numbering doesn't
            # overlap between the chain A protein and chain B RNA.
            ranges = "2-11,13-33,35-54"
            # 1 and 55 are 5' and 3' terminii which are a little looser.
            # 12, and 34 are bases that are not basepaired.
            ranges += ",104-105,115-136,145-190"
            # 106-114 is a loop
            # 137-144 is a loop
            # 191-193 are 3 Zn ions.

    #This leads to a procheck ranges file like:
    #        RESIDUES   2  B   11  B
    #        RESIDUES  13  B   33  B
    #        RESIDUES  35  B   54  B
    #        RESIDUES 104  A  105  A
    #        RESIDUES 115  A  136  A
    #        RESIDUES 145  A  190  A

        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        cyanaFile = os.path.join(cingDirTestsData, "cyana",
                                 entryId + ".cyana.tgz")
        self.assertTrue(project.initCyana(cyanaFolder=cyanaFile))
        project.molecule.setRanges(ranges)

        project.save()
        self.failIf(
            project.runProcheck(createPlots=True, runAqua=runAqua) is None)

        if showProcheckResults:
            for res in project.molecule.allResidues():
                nTdebug(repr(res) + " " + repr(res.procheck.secStruct))
Esempio n. 8
0
    def test_Whatif(self):
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
#        entryId = "2hgh" # Small much studied PDB NMR entry; 48 models
#        entryId = "1bus" # Small much studied PDB NMR entry:  5 models of 57 AA.: 285 residues.
        entryId = "1brv" # DEFAULT is not to do more than 2 models because it takes quite a while.
#        entryId = "1brv_cs_pk_2mdl"

#        entryId = "1tgq_1model"
#        pdbConvention = IUPAC
        parseOnly = False # normal is False
        showValues = True
        ranges='cv'
#        ranges='172-177'
#        ranges='6-13,29-45'


        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)
        project = Project( entryId )
        if not parseOnly:
            project.removeFromDisk()
            project = Project.open( entryId, status='new' )
            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)

            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile, modelCount=2))
            self.assertFalse(runWhatif(project, ranges=ranges, parseOnly=False))
        else:
            project = Project.open( entryId, status='old' )
#        print project.cingPaths.format()

        project.save()
        if showValues:
            for res in project.molecule.allResidues():
                nTdebug(repr(res))
                whatifResDict = res.getDeepByKeys(WHATIF_STR)
                if not whatifResDict:
                    continue
#                checkIDList = whatifResDict.keys()
                checkIDList = 'RAMCHK'.split()
                for checkID in checkIDList:
                    valueList = whatifResDict.getDeepByKeys(checkID,VALUE_LIST_STR)
                    qualList  = whatifResDict.getDeepByKeys(checkID,QUAL_LIST_STR)
                    nTdebug("%10s valueList: %-80s qualList: %-80s" % ( checkID, valueList, qualList))
        # 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))
Esempio n. 9
0
 def test_GetNextAvailableChainId(self):
     entryId = 'test'
     project = Project(entryId)
     self.failIf(project.removeFromDisk())
     project = Project.open(entryId, status='new')
     molecule = Molecule(name='moleculeName')
     project.appendMolecule(molecule) # Needed for html.
     chainId = molecule.getNextAvailableChainId()
     self.assertEquals( chainId, Chain.defaultChainId)
     n = 26 * 2 + 10 + 1 # alpha numeric including an extra and lower cased.
     for _c in range(n):
         chainId = molecule.getNextAvailableChainId()
         self.assertTrue( molecule.addChain(chainId))
     nTdebug("Added %d chains to: %s" % (n, molecule.format()))
     self.assertEqual( len(molecule.allChains()), n)
Esempio n. 10
0
 def _test_fullRedo(self):
     'Full recalculation and refinement by xplor nih. Too big to run by default.'
     nTdebug("Now in %s" % getCallerName())
     entryList  = "1brv_023     1dum                      ".split()
     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(entryList):
         if i != 0: # Selection of the entries.
             continue
         # end if
         inputArchiveDir = os.path.join(cingDirTestsData, "cing")
         cingDir =  entryId + ".cing"
         cingFileLocalTgz = entryId + ".cing.tgz"
         cingFile = os.path.join(inputArchiveDir, cingFileLocalTgz)
         if not os.path.exists(cingFile):
             self.fail("Neither %s or the .tgz exist" % cingFile)
         
         if os.path.exists(cingDir):
             rmtree(cingDir)
         if os.path.exists(cingFileLocalTgz):
             os.unlink( cingFileLocalTgz )
             
         copyfile(cingFile, cingFileLocalTgz )
         project = Project.open(entryId, status='old') 
         self.assertTrue(project)
         self.assertFalse(project.fullRedo(modelCountAnneal = 4, bestAnneal = 3, best = 2))
Esempio n. 11
0
    def test_exportXplor(self):
        modelCount = 1
        entryList = "1brv     2fws                      ".split()
        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(entryList):
            if i != 0:  # Selection of the entries.
                continue
            inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")
            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            if not os.path.exists(ccpnFile):
                self.fail("Neither %s or the .tgz exist" % ccpnFile)
            if not os.path.exists(entryId + ".tgz"):
                copyfile(ccpnFile, os.path.join('.', entryId + ".tgz"))

            project = Project.open(entryId, status='new')
            self.assertTrue(
                project.initCcpn(ccpnFolder=ccpnFile, modelCount=modelCount))
            molecule = project.molecule
            chain0 = molecule.allChains()[0]
            chain = molecule.removeChain(chain0)
            self.assertTrue(chain)
            if molecule.allChains():
                pdbFileName = entryId + "%03d.pdb"
                molecule.export2xplor(pdbFileName)
Esempio n. 12
0
    def _test_fullRedo(self):
        'Full recalculation and refinement by xplor nih. Too big to run by default.'
        nTdebug("Now in %s" % getCallerName())
        entryList = "1brv_023     1dum                      ".split()
        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(entryList):
            if i != 0:  # Selection of the entries.
                continue
            # end if
            inputArchiveDir = os.path.join(cingDirTestsData, "cing")
            cingDir = entryId + ".cing"
            cingFileLocalTgz = entryId + ".cing.tgz"
            cingFile = os.path.join(inputArchiveDir, cingFileLocalTgz)
            if not os.path.exists(cingFile):
                self.fail("Neither %s or the .tgz exist" % cingFile)

            if os.path.exists(cingDir):
                rmtree(cingDir)
            if os.path.exists(cingFileLocalTgz):
                os.unlink(cingFileLocalTgz)

            copyfile(cingFile, cingFileLocalTgz)
            project = Project.open(entryId, status='old')
            self.assertTrue(project)
            self.assertFalse(
                project.fullRedo(modelCountAnneal=4, bestAnneal=3, best=2))
Esempio n. 13
0
 def test_makeDihedralHistogramPlot(self):
     '''
     See test_NTplot2 for simpler test
     '''
     cing.verbosity = verbosityDebug
     cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
     mkdirs(cingDirTmpTest)
     self.failIf(os.chdir(cingDirTmpTest),
                 msg="Failed to change to test directory for files: " +
                 cingDirTmpTest)
     #        entryId = "1brv_cs_pk_2mdl"
     entryId = "2kq3"
     project = Project.open(entryId, status='new')
     inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")
     ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
     self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
     self.assertFalse(project.validateDihedrals())
     #        residue = project.molecule.A.PRO172
     residue = project.molecule.A.ASP19
     # Dihedral plots
     for dihed in residue.db.dihedrals.zap('name'):
         if dihed in residue and residue[dihed]:
             #                d = residue[dihed] # List of values with outliers etc attached.
             #                nTdebug("Residue %s: generating dihedral %s plot", residue, dihed )
             ps = makeDihedralHistogramPlot(project, residue, dihed)
             tmpPath = os.path.join(dihed + '.png')
             if ps and isinstance(ps, NTplotSet):
                 ps.hardcopy(fileName=tmpPath)
Esempio n. 14
0
    def _testNmrStar(self):
        "Testing conversion from CCPN to NMR-STAR using Wim Vranken's FC. Disabled test because only JFD uses it."
        # failing entries: 1ai0, 1kr8 (same for 2hgh)
        entryList = "1a4d".split()
#        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e SRYBDNA Parvulustat".split()
#1iv6 needs better ccpn file from FC
#        if you have a local copy you can use it; make sure to adjust the path setting below.
        useNrgArchive = False # Default is 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 entryId in entryList:
            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)
            else:
                inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile))
            self.assertTrue(project.save())
            fileName = os.path.join( cingDirTmp, entryId + ".str")
            nmrStar = NmrStar(project)
            self.assertTrue( nmrStar )
            self.assertTrue( nmrStar.toNmrStarFile( fileName ))
            # 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))
Esempio n. 15
0
    def test_makeDihedralHistogramPlot(self):
        '''
        See test_NTplot2 for simpler test
        '''
        cing.verbosity = verbosityDebug        
        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)        
#        entryId = "1brv_cs_pk_2mdl"        
        entryId = "2kq3"        
        project = Project.open(entryId, status = 'new')
        inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")
        ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
        self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile ))
        self.assertFalse( project.validateDihedrals() )
#        residue = project.molecule.A.PRO172
        residue = project.molecule.A.ASP19
        # Dihedral plots
        for dihed in residue.db.dihedrals.zap('name'):
            if dihed in residue and residue[dihed]:
#                d = residue[dihed] # List of values with outliers etc attached.
#                nTdebug("Residue %s: generating dihedral %s plot", residue, dihed )
                ps = makeDihedralHistogramPlot( project, residue, dihed )
                tmpPath = os.path.join( dihed + '.png')
                if ps and isinstance(ps, NTplotSet):
                    ps.hardcopy( fileName = tmpPath )
Esempio n. 16
0
    def test_exportXplor(self):
        modelCount = 1
        entryList  = "1brv     2fws                      ".split()
        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(entryList):
            if i != 0: # Selection of the entries.
                continue
            inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")
            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            if not os.path.exists(ccpnFile):
                self.fail("Neither %s or the .tgz exist" % ccpnFile)
            if not os.path.exists(entryId + ".tgz"):
                copyfile(ccpnFile, os.path.join('.', entryId + ".tgz"))

            project = Project.open(entryId, status = 'new')
            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile, modelCount=modelCount))
            molecule = project.molecule
            chain0 = molecule.allChains()[0]
            chain = molecule.removeChain(chain0)
            self.assertTrue( chain )
            if molecule.allChains():
                pdbFileName = entryId +"%03d.pdb"
                molecule.export2xplor( pdbFileName )
Esempio n. 17
0
    def _testDihedralComboPlot(self):
        ps = NTplotSet()  # closes any previous plots
        ps.hardcopySize = (image2DdihedralWidth, image2Ddihedralheight)
        dihedralName1 = 'PHI'
        dihedralName2 = 'PSI'
        projectName = 'testDihedralComboPlot'
        project = Project(projectName)
        plotparams1 = project.plotParameters.getdefault(
            dihedralName1, 'dihedralDefault')
        plotparams2 = project.plotParameters.getdefault(
            dihedralName1, 'dihedralDefault')

        plot = NTplot(title=projectName,
                      xRange=(plotparams1.min, plotparams1.max),
                      xTicks=range(int(plotparams1.min),
                                   int(plotparams1.max + 1),
                                   plotparams1.ticksize),
                      xLabel=dihedralName1,
                      yRange=(plotparams2.min, plotparams2.max),
                      yTicks=range(int(plotparams2.min),
                                   int(plotparams2.max + 1),
                                   plotparams2.ticksize),
                      yLabel=dihedralName2)

        ps.addPlot(plot)
        ps.hardcopy(projectName, 'png')
Esempio n. 18
0
    def test_BMRBcounts2(self):

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        entryId = '1brv'
        bmrbId = 4020
        inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")
        ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
        project = Project.open(entryId, status = 'new')
        self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile))
        assignmentCountMap = project.molecule.getAssignmentCountMap()
#        p_cs_count = assignmentCountMap['overall']
        p_cs1H_count = assignmentCountMap['1H']
        p_cs13C_count = assignmentCountMap['13C']
        p_cs15N_count = assignmentCountMap['15N']

        bmrbCountMap = getBmrbCsCounts()
        nTdebug("bmrbCountMap %r" % bmrbCountMap)
        entryMap = getDeepByKeysOrAttributes( bmrbCountMap, bmrbId )
        nTdebug("entryMap %r" % entryMap)
        d_cs1H_count = getDeepByKeysOrAttributes( entryMap, '1H' )
        d_cs13C_count = getDeepByKeysOrAttributes( entryMap, '13C' )
        d_cs15N_count = getDeepByKeysOrAttributes( entryMap, '15N' )

        nTdebug("db: %s project: %s" % ( d_cs1H_count, p_cs1H_count ) )
        nTdebug("db: %s project: %s" % ( d_cs13C_count, p_cs13C_count ) )
        nTdebug("db: %s project: %s" % ( d_cs15N_count, p_cs15N_count ) )
Esempio n. 19
0
    def test_pdb(self):

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        entryId = "1brv" # Small much studied PDB NMR entry
#        entryId = "tightTurn_IIb"
#        entryId = "1hy8" # small, single model, very low scoring entry

        pdbDirectory = os.path.join(cingDirTestsData,"pdb", entryId)
        pdbFileName = "pdb"+entryId+".ent"
        pdbFilePath = os.path.join( pdbDirectory, pdbFileName)

        # does it matter to import it just now?
        project = Project( entryId )
        self.failIf( project.removeFromDisk())
        project = Project.open( entryId, status='new' )
        project.initPDB( pdbFile=pdbFilePath, convention = IUPAC )

        m = project.molecule
        ranges = 'A.173-178'
        nTdebug("m: %s" % m)
        self.assertTrue( m.toPDB('m001.pdb', model=0, ranges=ranges, convention='XPLOR'))
#        nTdebug("Manual reimport")
#        m.initCoordinates()
#        m.importFromPDB('m001.pdb',convention='XPLOR')
        nTdebug("Reimport 1")
        m.replaceCoordinatesByPdb(pdbFilePath, name = entryId+'_reimport', convention=IUPAC)
#        nTdebug("Reimport 2")
#        m.replaceCoordinatesByPdb(pdbFilePath, name = entryId+'_reimport', useModels = "1", convention=IUPAC)

        self.assertFalse(project.mkMacros())
Esempio n. 20
0
    def testMolgrapRunFromPdbFile(self):
        #        SETUP FIRST
        #        entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
        #        entryId = "1a4d" # Small much studied PDB NMR entry
        #        entryId = "1zwj" # X-ray entry of CESG interest.
        entryId = "1brv"  # Small much studied PDB NMR entry
        #        entryId = "2hgh_1model"

        # does it matter to import it just now?
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        cyanaFile = os.path.join(cingDirTestsData, "cyana",
                                 entryId + ".cyana.tgz")
        self.assertTrue(project.initCyana(cyanaFolder=cyanaFile))
        project.save()
        gifFileName = entryId + ".gif"
        pathGif = os.path.join(self.cingDirTmpTest, gifFileName)
        self.assertFalse(project.molecule.export2gif(pathGif, project=project))
        self.assertTrue(os.path.exists(pathGif))
        pathMolGifPinup = pathGif[:-4] + '_pin.gif'
        self.assertTrue(os.path.exists(pathMolGifPinup))
        pathGifDefault = os.path.join(cingPythonCingDir, 'PluginCode',
                                      DATA_STR, 'UnknownImage.gif')
        self.assertFalse(
            os.path.getsize(pathGif) == os.path.getsize(pathGifDefault))
        nTmessage("Created new molecular imagery at: %s" % self.cingDirTmpTest)
Esempio n. 21
0
    def testROGscore(self):
        entryId = 'test'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        molecule.ensemble = Ensemble(molecule)  # Needed for html.
        project.appendMolecule(molecule)  # Needed for html.

        # Add some crud to prevent warnings/errors later.
        molecule.addChain('top')
        top = molecule.allChains()[0]
        # Disable warnings temporarily
        v = cing.verbosity
        cing.verbosity = verbosityNothing
        for i in range(1 * 10):
            res = top.addResidue(repr(random()), i)
            for j in range(5):
                _atom = res.addAtom(repr(random()), j)
        cing.verbosity = v

        molecule.updateAll()
        project.setupHtml()  # Needed for creating the sub dirs.

        a = Atom(resName='ALA', atomName='HN')
        a.criticize()
        self.assertTrue(a)
        self.assertEquals(a.rogScore.colorLabel, COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][0], COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][1],
                          ROGscore.ROG_COMMENT_NO_COOR)
        lotr_remark = 'One ring to rule them all'
        preserved_remark = 'Preserved'
        nowHasEffect_remark = 'Now has effect'
        nowHasEffectToo_remark = 'Now has effect too'
        # Next line will have to wipe out the orange comments.
        a.rogScore.setMaxColor(COLOR_RED, lotr_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffect_remark)
        a.rogScore.setMaxColor(COLOR_RED, preserved_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffectToo_remark)
        self.assertEquals(len(a.rogScore.colorCommentList), 5)
        self.assertEquals(a.rogScore.colorCommentList[0][1],
                          ROGscore.ROG_COMMENT_NO_COOR)
        self.assertEquals(a.rogScore.colorCommentList[1][1],
                          nowHasEffect_remark)

        myhtml = HTMLfile('testROGscore.html', project, 'A Test')
        myhtml.main("a main")
        a.rogScore.createHtmlForComments(myhtml.main)

        kw = {}
        a.rogScore.addHTMLkeywords(kw)
        myhtml.main("a", 'or by popup', **kw)
        myhtml.render()
Esempio n. 22
0
    def loadProject(self):
        modelCount = 1
        ccpnFile = self.compressedCcpnProject
        project = Project.open(self.idCode, status='new')
        # Can read tgz files.
        if project.initCcpn(ccpnFolder=ccpnFile, modelCount=modelCount) == None:
            nTerror("Failed to read: %s" % ccpnFile)
            return True
#        self.ccpnProject = loadCcpnTgzProject(os.path.join(self.loadDir, self.idCode, 'linkNmrStarData'))
        self.ccpnProject = project.ccpn
Esempio n. 23
0
    def _test_cingTestData(self): # Disabled all together because JFD can't figure out why it works on all but the master node.
        # and even there it works fine when testing manually with right setup and:
        # nosetests /Users/jd/.jenkins/jobs/CING/workspace/Slaves/master/python/cing/PluginCode/test/test_cingTestData.py
        entryList = "1brv_023 1brv_024 1brv_025".split() # 0.24 version project with CS from NRG-CING.
#        entryList = "1brv_024 1brv_025".split() # 0.23 version skipped because unknown error causes it to fail.
#        entryList = "1brv_025".split()
#        entryList = "H2_2Ca_64_100".split()   # 0.24 version project with CS.
#        entryList = "1i1s 1ka3 1tgq 1y4o".split()
#        if you have a local copy you can use it; make sure to adjust the path setting below.
        validateFastest = True

        htmlOnly = False # default is False but enable it for faster runs without some actual data.
        doWhatif = False # disables whatif actual run
        doProcheck = False
        doWattos = False
        useNrgArchive = 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 entryId in entryList:
            nTmessage('Doing %s' % 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('/Library/WebServer/Documents/NRG-CING/recoordSync', entryId)
                inputArchiveDir = os.path.join('/Users/jd/ccpn_tmp/data/recoord', entryId)
            else:
                inputArchiveDir = os.path.join(cingDirTestsData, "cing")
            # end if
            cingFile = os.path.join(inputArchiveDir, entryId + ".cing.tgz")
            self.assertTrue( os.path.exists(cingFile), "Failed to find file: " + cingFile)

            cingDirNew = os.path.join(cingDirTestsData, entryId + ".cing")
            if os.path.exists(cingDirNew):
                nTmessage("Removing old cing project directory: " + cingDirNew )
                shutil.rmtree( cingDirNew )
            # end if
            shutil.copy(cingFile, cingDirTmpTest)
            project = Project.open(entryId, status = 'old')
            self.assertTrue(project, 'Failed opening project: ' + entryId)

            if 1:
                self.assertFalse(project.validate(htmlOnly = htmlOnly,
                                                  doProcheck = doProcheck,
                                                  doWhatif = doWhatif,
                                                  doWattos=doWattos,
                                                  validateFastest=validateFastest ))
            # end if
            self.assertTrue(project.save())
            # 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))
Esempio n. 24
0
def changeCoordinates(proj_path, prl_name):
    '''
    Load the coordinates from the PDB file into CING project.
    NB: also already saves the project.
    Return True on error.    
    '''
    prl = Project.open('%s/%s' % (proj_path, prl_name), status='old')
    molec = prl.molecule
    molec.initCoordinates()
    molec.importFromPDB('%s/%s.pdb' % (proj_path, prl_name), convention='IUPAC')
    prl.save()
Esempio n. 25
0
    def test_Procheck(self):
        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        runAqua = True
        showProcheckResults = False
        #entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
        entryId = "1bus"
#        entryId = "1brv_1model" # Small much studied PDB NMR entry
        ranges = None

        if entryId.startswith("1brv"):
            ranges = "173-186"

        if entryId.startswith("1ai0"):
            ranges = "2-20"

        if entryId == "2hgh":
            # in the case of 2hgh this is not a problem because the residue numbering doesn't
            # overlap between the chain A protein and chain B RNA.
            ranges = "2-11,13-33,35-54"
                # 1 and 55 are 5' and 3' terminii which are a little looser.
                # 12, and 34 are bases that are not basepaired.
            ranges += ",104-105,115-136,145-190"
                # 106-114 is a loop
                # 137-144 is a loop
                # 191-193 are 3 Zn ions.
    #This leads to a procheck ranges file like:
    #        RESIDUES   2  B   11  B
    #        RESIDUES  13  B   33  B
    #        RESIDUES  35  B   54  B
    #        RESIDUES 104  A  105  A
    #        RESIDUES 115  A  136  A
    #        RESIDUES 145  A  190  A


        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        project = Project( entryId )
        self.failIf( project.removeFromDisk() )
        project = Project.open( entryId, status='new' )
        cyanaFile = os.path.join(cingDirTestsData, "cyana", entryId + ".cyana.tgz")
        self.assertTrue(project.initCyana(cyanaFolder = cyanaFile))
        project.molecule.setRanges(ranges)

        project.save()
        self.failIf(project.runProcheck(createPlots=True, runAqua=runAqua) is None)

        if showProcheckResults:
            for res in project.molecule.allResidues():
                nTdebug(repr(res) +" "+ repr(res.procheck.secStruct))
Esempio n. 26
0
    def open(self, path, status='old'):
        """
        Open a project and append
        return project or None on error
        """
        project = Project.open( path, status=status)
        if not project:
            nTerror('Projects.open: aborting')
            sys.exit(1)

        self.append( project )
        return project
Esempio n. 27
0
def upgrade100(project, restore):
    """
    Do all things to upgrade project to current configuration
    All versions <= 1.00
    """
    nTmessage('*** upgrade100: upgrading %s from version %s ***', project, project.version)
    verbosity = cing.verbosity
    # make sure we get all if we heave debug on
    if cing.verbosity < cing.verbosityDebug:
        cing.verbosity = cing.verbosityWarning

    # Molecules
    for molName in project.moleculeNames:
        pathName = project.molecules.path(molName)
        mol = Molecule.open(pathName)
        if mol:
            mol.status = 'keep'
            project.appendMolecule(mol)
        #end if
        nTdebug('upgrade100: restored %s', mol)
    #end for

    # restore the lists
    for pl in [project.peaks, project.distances, project.dihedrals, project.rdcs, project.coplanars]:
        pl.restore()
    #end for

    # Now patch talos+
    nTmessage('==> upgrade100: talosPlus')
    if restoreTalosPlus100(project):
        io.error('upgrade100: restoring talosPlus data failed\n')

    # Now patch queeny
    # nTmessage('==> upgrade100: queeny')
    # if restoreQueeny100(project):
    #     nTerror('upgrade100: restoring queeny data failed')
    # project.saveQueeny()
    #
    # # Now patch shiftx
    # if restoreShiftx100(project):
    #     nTerror('upgrade100: restoring shiftx data failed')
    #     return None
    # project.saveShiftx()

    # Plugin registered functions
    nTdebug('upgrade100: calling plugins')
    project._callPluginRestores()

    # save to consolidate
    project.save()

    cing.verbosity = verbosity
    return Project.open(project.name, constants.PROJECT_OLD, restore=restore)
Esempio n. 28
0
    def test_Wattos(self):
        "Testing wattos reading and working on a star file that first gets created by Wim's FC."

        # failing entries: 1ai0, 1kr8 (same for 2hgh)
        #        entryList = "1kr8".split()
        entryList = "1brv".split()
        #        entryList = "basp2".split()
        #        entryList = "1bus".split()
        #        entryList = "1a4d".split()
        #        entryList = "2k0e_all".split()
        #        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e SRYBDNA Parvulustat".split()
        #        entryList = "1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e".split()
        #1iv6 needs better ccpn file from FC
        #        entryList = ["Parvulustat"]
        #        entryList = ["SRYBDNA"]

        #        if you have a local copy you can use it; make sure to adjust the path setting below.
        useNrgArchive = False  # Default is False
        ranges = 'cv'
        #        ranges='16-29'

        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)
        for entryId in entryList:
            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)
            else:
                inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
            #            self.assertTrue(project.save())
            self.assertFalse(project.molecule.setRanges(ranges))
            self.assertTrue(runWattos(project))
            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

            self.assertTrue(completenessMol)
Esempio n. 29
0
def changeCoordinates(proj_path, prl_name):
    '''
    Load the coordinates from the PDB file into CING project.
    NB: also already saves the project.
    Return True on error.    
    '''
    prl = Project.open('%s/%s' % (proj_path, prl_name), status='old')
    molec = prl.molecule
    molec.initCoordinates()
    molec.importFromPDB('%s/%s.pdb' % (proj_path, prl_name),
                        convention='IUPAC')
    prl.save()
Esempio n. 30
0
    def testPdbFile(self):
        nTwarning(
            "This test case will take about 5 (+3 for 1v0e) minutes and is recommended to be done before major releases."
        )
        #        entryId = "1ai0" # Most complex molecular system in any PDB NMR entry
        #        entryId = "1brv" # Small much studied PDB NMR entry
        #        entryId = "2hgh_1model"
        #        entryList = "1kr8".split()
        #        entryList = "1otz".split() # 61 chains of which one is ' '
        #        entryList = "1v0e".split()
        #        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 1otz 2hgh 2k0e".split()
        entryList = "1a4d 1ai0 1brv 1bus 1hue 1iv6 1kr8".split()
        for entryId in entryList:

            pdbDirectory = os.path.join(cingDirTestsData, "pdb", entryId)
            pdbFileName = "pdb" + entryId + ".ent"
            pdbFilePath = os.path.join(pdbDirectory, pdbFileName)

            cingDirTmpTest = os.path.join(cingDirTmp, 'test2_pdb')
            mkdirs(cingDirTmpTest)
            os.chdir(cingDirTmpTest)
            # does it matter to import it just now?
            project = Project(entryId)
            self.failIf(project.removeFromDisk())
            project = Project.open(entryId, status='new')
            self.assertTrue(
                project.initPDB(pdbFile=pdbFilePath,
                                convention=IUPAC,
                                allowNonStandardResidue=True))
            self.assertTrue(project.save())
Esempio n. 31
0
    def test_pdb(self):

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        entryId = "1brv" # Small much studied PDB NMR entry
#        entryId = "tightTurn_IIb"
#        entryId = "1hy8" # small, single model, very low scoring entry

        pdbDirectory = os.path.join(cingDirTestsData,"pdb", entryId)
        pdbFileName = "pdb"+entryId+".ent"
        pdbFilePath = os.path.join( pdbDirectory, pdbFileName)

        # does it matter to import it just now?
        project = Project( entryId )
        self.failIf( project.removeFromDisk())
        project = Project.open( entryId, status='new' )
        project.initPDB( pdbFile=pdbFilePath, convention = IUPAC )

        m = project.molecule
        ranges = 'A.173-178'
        nTdebug("m: %s" % m)
        self.assertTrue( m.toPDB('m001.pdb', model=0, ranges=ranges, convention='XPLOR'))
#        nTdebug("Manual reimport")
#        m.initCoordinates()
#        m.importFromPDB('m001.pdb',convention='XPLOR')
        nTdebug("Reimport 1")
        m.replaceCoordinatesByPdb(pdbFilePath, name = entryId+'_reimport', convention=IUPAC)
#        nTdebug("Reimport 2")
#        m.replaceCoordinatesByPdb(pdbFilePath, name = entryId+'_reimport', useModels = "1", convention=IUPAC)

        self.assertFalse(project.mkMacros())
Esempio n. 32
0
    def test_AddResidue_Standard(self):
        entryId = 'test'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')

        mol = Molecule('test')
        project.appendMolecule(mol)
        c = mol.addChain('A')
        r1 = c.addResidue('ALA', 1, Nterminal=True)
        if r1:
            r1.addAllAtoms()
        r2 = c.addResidue('VAL', 2)
        if r2:
            r2.addAllAtoms()
        r2 = c.addResidue('PHE', 3)
        if r2:
            r2.addAllAtoms()
        r2 = c.addResidue('ARG', 4)
        if r2:
            r2.addAllAtoms()
        r3 = c.addResidue('GLU', 5, Cterminal=True)
        if r3:
            r3.addAllAtoms()

        mol.updateAll()

        nTmessage(mol.format())
Esempio n. 33
0
    def test_xplor_nih(self):
        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        entryId = "gb1"
        pdbDirectory = os.path.join(cingDirTestsData,"xplor", entryId)
        pdbFileName = entryId+".pdb"
        pdbFilePath = os.path.join( pdbDirectory, pdbFileName)

        project = Project( entryId )
        self.failIf( project.removeFromDisk())
        project = Project.open( entryId, status='new' )
        project.initPDB( pdbFile=pdbFilePath, convention = XPLOR )
#        project.validate(ranges, parseOnly, htmlOnly, doProcheck, doWhatif, doWattos, doTalos)
        project.validate(htmlOnly=True, doProcheck=False, doWhatif=False, doWattos=False, doTalos=False)
        project.save()
Esempio n. 34
0
    def _testAnalysisRpf(self):
        'Skip until project has been improved; looks like peaks without CS are found.'
        #        if you have a local copy you can use it; make sure to adjust the path setting below.
        fastestTest = True

        modelCount = 99
        if fastestTest:
            modelCount = 2

        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        for entryId in AllChecks.entryList:
            project = Project.open(entryId, status='new')
            self.assertTrue(project, 'Failed opening project: ' + entryId)

            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)

            self.assertTrue(
                project.initCcpn(ccpnFolder=ccpnFile, modelCount=modelCount))

            analysis = Analysis(project)
            if analysis.initAnalysis():
                self.fail("%s Failed to analysis.initAnalysis()" % entryId)
                continue

            # If unit testing without output then Analysis needs to be silenced separately.
            if cing.verbosity <= cing.verbosityNothing:
                switchOutput(False)

            self.assertTrue(
                analysis.runRpf(
                    doAlised=DEFAULT_CONSIDER_ALIASED_POSITIONS,
                    distThreshold=DEFAULT_DISTANCE_THRESHOLD,
                    prochiralExclusion=DEFAULT_PROCHIRAL_EXCLUSION_SHIFT,
                    diagonalExclusion=DEFAULT_DIAGONAL_EXCLUSION_SHIFT))

            if cing.verbosity <= cing.verbosityNothing:
                switchOutput(True)

            self.assertTrue(project.save())
            del project
            del analysis  # Calls quit?
Esempio n. 35
0
def run():
    nTdebug("Remove previous project if present")
    pdir = n+".cing"
    if os.path.exists(pdir):
        rmtree(pdir)
    nTdebug("Load project from .tgz")
    project = Project.open(n, status='old')
    if not project:
        sys.exit(1)
    nTdebug("Set convenience variables")
    m = project.molecule
    rangesNew = m.rangesByCv()
    nTdebug("rangesNew: %s" % rangesNew)
Esempio n. 36
0
    def createSimpleFastProject(self):
        'create simple fast project'
        entryId = 'test'

        self.project = Project(entryId)
        self.project.removeFromDisk()
        self.project = Project.open(entryId, status='new')

        mol = Molecule('test')
        self.project.appendMolecule(mol)
        c = mol.addChain('A')
        self.r1 = c.addResidue('VAL', 1, Nterminal=True)
        self.r2 = c.addResidue('VAL', 2)
        self.r3 = c.addResidue('GLU', 3)
        self.r4 = c.addResidue('TYR', 4)
        self.r5 = c.addResidue('PHE', 5)
        self.r6 = c.addResidue('GLY', 6)
        self.r7 = c.addResidue('ARG', 7)
        self.r8 = c.addResidue('LEU', 8, Cterminal=True)
        for r in mol.allResidues():
            r.addAllAtoms()
        mol.updateAll()
Esempio n. 37
0
def run():
    nTdebug("Remove previous project if present")
    pdir = n + ".cing"
    if os.path.exists(pdir):
        rmtree(pdir)
    nTdebug("Load project from .tgz")
    project = Project.open(n, status='old')
    if not project:
        sys.exit(1)
    nTdebug("Set convenience variables")
    m = project.molecule
    rangesNew = m.rangesByCv()
    nTdebug("rangesNew: %s" % rangesNew)
Esempio n. 38
0
    def test_TalosPlus(self):
        if not cingPaths.talos:
            raise ImportWarning('No Talos installed.')

#        if you have a local copy you can use it; make sure to adjust the path setting below.
        fastestTest = True

        modelCount = 99
        if fastestTest:
            modelCount = 2

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        for entryId in AllChecks.entryList:
            project = Project.open(entryId, status='new')
            self.assertTrue(project, 'Failed opening project: ' + entryId)
            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)

            self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile, modelCount=modelCount))
#            self.assertFalse(project.runTalosPlus())
#            self.assertTrue(project.save())
            self.assertFalse(project.validate(htmlOnly=True, doProcheck=False, doWhatif=False, doWattos=False, doQueeny=False))
            for r, res in enumerate(project.molecule.allResidues()):
                nTdebug("Working on %s" % res)
                for c, valueToCheck in enumerate(keyList):
                    if c == 2: # TODO: re-enable this check when debugged.
                        continue
                    valueDetermined = getDeepByKeysOrAttributes(res, TALOSPLUS_STR, valueToCheck)
                    valueReference = valueKnownList[r][c] # r/c is for row/column
                    if isNaN(valueDetermined) and isNaN(valueReference):
                        continue
                    if isNaN(valueDetermined) or isNaN(valueReference):
                        self.fail("Working on %s %s %s valueDetermined %s is not valueReference %s because only one of them isNaN" % (
                                res, c, valueToCheck, valueDetermined, valueReference))
                    self.assertAlmostEquals(valueReference, valueDetermined, 3)
            self.assertTrue(project.save())
#            project.close()
#            del project
#
#            project = Project.open(entryId, status = 'old')
            # 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))
Esempio n. 39
0
    def test_superpose(self):
        pdbConvention = IUPAC
        entryId = "1brv"
#        entryId = "2vb1_simple" # Protein solved by X-ray.

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        pdbDirectory = os.path.join(cingDirTestsData,"pdb", entryId)
        pdbFileName = "pdb" + entryId + ".ent"
        pdbFilePath = os.path.join( pdbDirectory, pdbFileName)
        self.failIf( not os.path.exists(pdbFilePath), msg= "Failed to find file: "+pdbFilePath)

        # does it matter to import it just now?
        project = Project( entryId )
        self.failIf( project.removeFromDisk())
        project = Project.open( entryId, status='new' )
        project.initPDB( pdbFile=pdbFilePath, convention = pdbConvention )

        # Compare with molmol on 1brv's 48 models:
#        mean global bb    RMSD:  0.98 +/-  0.40 A  ( 0.10.. 2.19 A)
#        mean global heavy RMSD:  1.75 +/-  0.51 A  ( 0.54.. 3.33 A)
        # Note that in molmol the backbone protein atoms are defined: N, CA, C
        # CING used to include the carbonyl atom

        # using default parameters.
        ens = project.molecule.superpose(backboneOnly=True, includeProtons = False, iterations=2)
        nTdebug( 'ens %s' % ens)
        nTdebug( 'ens.averageModel %s' % ens.averageModel)
        self.assertAlmostEquals( 0.7643199324863148, ens.averageModel.rmsd, 3 )
        # Confirmed to be the 'averaage RMSD to mean: 0.698' in molmol using command
        #    Fit 'to_mean'.
        ens = project.molecule.superpose(backboneOnly=False, includeProtons = False,
                                         iterations=3) # no improvement to do 3 over the default 2 but left in for speed checking.
        nTdebug( 'ens.averageModel %s' % ens.averageModel)
        self.assertAlmostEquals( 0.99383582432002637, ens.averageModel.rmsd, 3 )
Esempio n. 40
0
    def createSimpleFastProject(self):
        'create simple fast project'
        entryId = 'test'

        self.project = Project( entryId )
        self.project.removeFromDisk()
        self.project = Project.open( entryId, status='new' )


        mol = Molecule('test')
        self.project.appendMolecule(mol)
        c = mol.addChain('A')
        self.r1 = c.addResidue('VAL', 1, Nterminal = True)
        self.r2 = c.addResidue('VAL', 2)
        self.r3 = c.addResidue('GLU', 3)
        self.r4 = c.addResidue('TYR', 4)
        self.r5 = c.addResidue('PHE', 5)
        self.r6 = c.addResidue('GLY', 6)
        self.r7 = c.addResidue('ARG', 7)
        self.r8 = c.addResidue('LEU', 8, Cterminal = True)
        for r in mol.allResidues():
            r.addAllAtoms()
        mol.updateAll()
Esempio n. 41
0
    def test_xplor_nih(self):
        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        entryId = "gb1"
        pdbDirectory = os.path.join(cingDirTestsData, "xplor", entryId)
        pdbFileName = entryId + ".pdb"
        pdbFilePath = os.path.join(pdbDirectory, pdbFileName)

        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        project.initPDB(pdbFile=pdbFilePath, convention=XPLOR)
        #        project.validate(ranges, parseOnly, htmlOnly, doProcheck, doWhatif, doWattos, doTalos)
        project.validate(htmlOnly=True,
                         doProcheck=False,
                         doWhatif=False,
                         doWattos=False,
                         doTalos=False)
        project.save()
Esempio n. 42
0
    def _testAnalysisRpf(self):
        'Skip until project has been improved; looks like peaks without CS are found.'
#        if you have a local copy you can use it; make sure to adjust the path setting below.
        fastestTest = True

        modelCount=99
        if fastestTest:
            modelCount=2

        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        for entryId in AllChecks.entryList:
            project = Project.open(entryId, status = 'new')
            self.assertTrue(project, 'Failed opening project: ' + entryId)

            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)

            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile, modelCount=modelCount))

            analysis = Analysis(project)
            if analysis.initAnalysis():
                self.fail("%s Failed to analysis.initAnalysis()" % entryId)
                continue

            # If unit testing without output then Analysis needs to be silenced separately.
            if cing.verbosity <= cing.verbosityNothing:
                switchOutput(False)

            self.assertTrue(analysis.runRpf(
                doAlised=DEFAULT_CONSIDER_ALIASED_POSITIONS,
                distThreshold=DEFAULT_DISTANCE_THRESHOLD,
                prochiralExclusion=DEFAULT_PROCHIRAL_EXCLUSION_SHIFT,
                diagonalExclusion=DEFAULT_DIAGONAL_EXCLUSION_SHIFT
                ))

            if cing.verbosity <= cing.verbosityNothing:
                switchOutput(True)

            self.assertTrue(project.save())
            del project
            del analysis # Calls quit?
Esempio n. 43
0
    def setupSimplestProject(self):
        entryId = 'setupSimplestProject'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        molecule.ensemble = Ensemble(molecule)  # Needed for html.
        project.appendMolecule(molecule)  # Needed for html.
        c = molecule.addChain('A')
        r1 = c.addResidue('ALA', 1, Nterminal=True)
        if r1:
            r1.addAllAtoms()

        molecule.updateAll()
        project.setupHtml()  # Needed for creating the sub dirs.
        return project
Esempio n. 44
0
    def test_x3dna(self):
        if osType != OS_TYPE_MAC:  # only installed for mac os currently.
            return
        try:
            from cing.PluginCode.x3dna import createHtmlX3dna
        except:
            nTerror("Failed to import x3dna on a mac osx.")
            return
        entryList = "1b4y".split(
        )  # triple helix but it only gets analyzed to a double helix.
        #        entryList = "1cjg".split()
        #        entryList = "2hgh".split()
        #        entryList = "1a4d".split()
        #        entryList = "1brv".split() # protein only entry
        #        entryList = ["SRYBDNA"]

        useNrgArchive = False
        showValues = True
        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        for entryId in entryList:
            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)
            else:
                inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
            project.save()
            self.assertTrue(project.runX3dna())
            project.save()
            self.assertFalse(createHtmlX3dna(project))

            if showValues:
                for coplanar in project.coplanars[0]:
                    #                    nTdebug(coplanar.format())
                    nTdebug('%r' % coplanar[X3DNA_STR])

            # 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))
Esempio n. 45
0
    def testROGscore(self):
        entryId = 'test'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        molecule.ensemble = Ensemble(molecule) # Needed for html.
        project.appendMolecule(molecule) # Needed for html.

        # Add some crud to prevent warnings/errors later.
        molecule.addChain('top')
        top = molecule.allChains()[0]
        # Disable warnings temporarily
        v = cing.verbosity
        cing.verbosity = verbosityNothing
        for i in range( 1*10):
            res = top.addResidue( repr(random()),i )
            for j in range( 5):
                _atom = res.addAtom( repr(random()),j )
        cing.verbosity = v


        molecule.updateAll()
        project.setupHtml() # Needed for creating the sub dirs.

        a = Atom(resName='ALA', atomName='HN')
        a.criticize()
        self.assertTrue(a)
        self.assertEquals(a.rogScore.colorLabel, COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][0], COLOR_ORANGE)
        self.assertEquals(a.rogScore.colorCommentList[0][1], ROGscore.ROG_COMMENT_NO_COOR)
        lotr_remark = 'One ring to rule them all'
        preserved_remark = 'Preserved'
        nowHasEffect_remark = 'Now has effect'
        nowHasEffectToo_remark = 'Now has effect too'
        # Next line will have to wipe out the orange comments.
        a.rogScore.setMaxColor(COLOR_RED, lotr_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffect_remark )
        a.rogScore.setMaxColor(COLOR_RED, preserved_remark)
        a.rogScore.setMaxColor(COLOR_ORANGE, nowHasEffectToo_remark)
        self.assertEquals(len(a.rogScore.colorCommentList), 5)
        self.assertEquals(a.rogScore.colorCommentList[0][1], ROGscore.ROG_COMMENT_NO_COOR)
        self.assertEquals(a.rogScore.colorCommentList[1][1], nowHasEffect_remark)

        myhtml = HTMLfile('testROGscore.html', project, 'A Test')
        myhtml.main("a main")
        a.rogScore.createHtmlForComments(myhtml.main)

        kw = {}
        a.rogScore.addHTMLkeywords(kw)
        myhtml.main("a", 'or by popup', **kw)
        myhtml.render()
Esempio n. 46
0
    def test_Wattos(self):
        "Testing wattos reading and working on a star file that first gets created by Wim's FC."

        # failing entries: 1ai0, 1kr8 (same for 2hgh)
#        entryList = "1kr8".split()
        entryList = "1brv".split()
#        entryList = "basp2".split()
#        entryList = "1bus".split()
#        entryList = "1a4d".split()
#        entryList = "2k0e_all".split()
#        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e SRYBDNA Parvulustat".split()
#        entryList = "1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e".split()
#1iv6 needs better ccpn file from FC
#        entryList = ["Parvulustat"]
#        entryList = ["SRYBDNA"]

#        if you have a local copy you can use it; make sure to adjust the path setting below.
        useNrgArchive = False # Default is False
        ranges='cv'
#        ranges='16-29'


        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)
        for entryId in entryList:
            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)
            else:
                inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile))
#            self.assertTrue(project.save())
            self.assertFalse(project.molecule.setRanges(ranges))
            self.assertTrue(runWattos(project))
            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

            self.assertTrue(completenessMol)
Esempio n. 47
0
    def test_cyana2cing(self):
        #        SETUP FIRST
        projectId = "1pdb"
        cyanaDirectory = os.path.join(cingDirTestsData, "cyana", projectId)
        self.assertTrue(
            os.path.exists(cyanaDirectory) and os.path.isdir(cyanaDirectory))

        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        projectRootPath = os.path.join(cingDirTmp, projectId)
        projectRoot = Project.rootPath(projectRootPath)[
            0]  # xeasy_project.cing in /tmp
        if os.path.exists(projectRoot):
            nTwarning(
                'Output directory "%s" already exists. It will now be removed.'
                % projectRoot)
            self.failIf(shutil.rmtree(projectRoot),
                        "Failed to remove old project directory.")

        project = Project.open(projectRootPath, 'new')
        project.cyana2cing(  #project=project,
            cyanaDirectory=cyanaDirectory,
            uplFiles=[projectId],
            acoFiles=[projectId, "talos"],
            pdbFile=projectId,
            nmodels=2,
            copy2sources=True)

        if not project:
            nTwarning("No project generated. Aborting further execution.")
            sys.exit(0)
        project.save()
Esempio n. 48
0
    def _test_2ccpn(self):
        # failing entries: 1ai0, 1kr8 (same for 2hgh)
        entryList = "1iv6".split()
        #        entryList = "1brv".split()
        #        entryList = "1a4d".split()
        #        entryList = "2k0e_all".split()
        #        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e".split()
        #        entryList =            "1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e SRYBDNA Parvulustat".split()
        #1iv6 needs better ccpn file from FC
        #        entryList = ["Parvulustat"]
        #        entryList = ["1a4d"]

        fastestTest = True
        htmlOnly = True  # default is False but enable it for faster runs without some actual data.
        doWhatif = True  # disables whatif actual run
        doProcheck = True
        doWattos = True
        if fastestTest:
            htmlOnly = True
            doWhatif = False
            doProcheck = False
            doWattos = 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 entryId in entryList:
            project = Project.open(entryId, status='new')
            self.assertTrue(project, 'Failed opening project: ' + entryId)

            ccpnFile = os.path.join(cingDirTestsData, "ccpn", entryId + ".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
            self.assertTrue(project.save())
            self.assertFalse(
                project.validate(
                    htmlOnly=htmlOnly,
                    doProcheck=doProcheck,
                    doWhatif=doWhatif,
                    doWattos=doWattos,
                ))
            #            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))
Esempio n. 49
0
    def test_x3dna(self):
        if cing.systemDefinitions.osType != OS_TYPE_MAC: # only installed for mac os currently.
            return
        try:
            from cing.PluginCode.x3dna import createHtmlX3dna
        except:
            nTerror("Failed to import x3dna on a mac osx.")
            return
        entryList = "1b4y".split() # triple helix but it only gets analyzed to a double helix.
#        entryList = "1cjg".split()
#        entryList = "2hgh".split()
#        entryList = "1a4d".split()
#        entryList = "1brv".split() # protein only entry
#        entryList = ["SRYBDNA"]

        useNrgArchive = False
        showValues = True
        cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
        mkdirs( cingDirTmpTest )
        self.failIf(os.chdir(cingDirTmpTest), msg =
            "Failed to change to test directory for files: " + cingDirTmpTest)

        for entryId in entryList:
            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)
            else:
                inputArchiveDir = os.path.join(cingDirTestsData, "ccpn")

            ccpnFile = os.path.join(inputArchiveDir, entryId + ".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder = ccpnFile))
            project.save()
            self.assertTrue(project.runX3dna())
            project.save()
            self.assertFalse(createHtmlX3dna(project))

            if showValues:
                for coplanar in project.coplanars[0]:
#                    nTdebug(coplanar.format())
                    nTdebug('%r' % coplanar[X3DNA_STR])

            # 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))
Esempio n. 50
0
    def setupSimplestProject(self):
        entryId = 'setupSimplestProject'
        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        molecule = Molecule(name='moleculeName')
        molecule.ensemble = Ensemble(molecule) # Needed for html.
        project.appendMolecule(molecule) # Needed for html.
        c = molecule.addChain('A')
        r1 = c.addResidue('ALA', 1, Nterminal = True)
        if r1:
            r1.addAllAtoms()

        molecule.updateAll()
        project.setupHtml() # Needed for creating the sub dirs.
        return project
Esempio n. 51
0
    def _testCreateCcpn(self):
        'Disabled test because...'
        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        for entryId in AllChecks.entryList:
            # Allow pdb files to be of different naming systems for this test.
            project = Project(entryId)
            self.failIf(project.removeFromDisk())
            project = Project.open(entryId, status='new')

            cyanaFolder = os.path.join(cingDirTestsData, "cyana",
                                       entryId + ".cyana.tgz")
            nTdebug("Reading files from: " + cyanaFolder)
            project.initCyana(cyanaFolder)

            project.save()
            nTmessage("Project: %s" % project)
            ccpnFolder = entryId + "New"
            self.assertTrue(project.saveCcpn(ccpnFolder))
Esempio n. 52
0
    def _testMolgrapRunFromCcpnFile(self):
        #        entryId = "1cjg" # Nucleic acid entry.

        entryId = "1brv"  # Nucleic acid entry.
        project = Project.open(entryId, status='new')
        self.assertTrue(project, 'Failed opening project: ' + entryId)

        ccpnFile = os.path.join(cingDirTestsData, "ccpn", entryId + ".tgz")
        self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
        self.assertTrue(project.save())

        gifFileName = entryId + ".gif"
        pathGif = os.path.join(cingDirTmp, gifFileName)
        self.assertFalse(project.molecule.export2gif(pathGif, project=None))
        self.assertTrue(os.path.exists(pathGif))
        # 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))
Esempio n. 53
0
    def _testMolgrapRunFromCcpnFile(self):
#        entryId = "1cjg" # Nucleic acid entry.

        entryId = "1brv" # Nucleic acid entry.
        project = Project.open( entryId, status='new' )
        self.assertTrue(project, 'Failed opening project: ' + entryId)

        ccpnFile = os.path.join(cingDirTestsData,"ccpn", entryId+".tgz")
        self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
        self.assertTrue(project.save())

        gifFileName = entryId+".gif"
        pathGif = os.path.join( cingDirTmp, gifFileName)
        self.assertFalse(project.molecule.export2gif(pathGif, project=None))
        self.assertTrue(os.path.exists(pathGif))
        # 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))
Esempio n. 54
0
    def _test_2ccpn(self):
        # failing entries: 1ai0, 1kr8 (same for 2hgh)
        entryList = "1iv6".split()
#        entryList = "1brv".split()
#        entryList = "1a4d".split()
#        entryList = "2k0e_all".split()
#        entryList = "1a4d 1a24 1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e".split()
#        entryList =            "1afp 1ai0 1brv 1bus 1cjg 1hue 1ieh 1iv6 1kr8 2hgh 2k0e SRYBDNA Parvulustat".split()
#1iv6 needs better ccpn file from FC
#        entryList = ["Parvulustat"]
#        entryList = ["1a4d"]

        fastestTest = True
        htmlOnly = True # default is False but enable it for faster runs without some actual data.
        doWhatif = True # disables whatif actual run
        doProcheck = True
        doWattos = True
        if fastestTest:
            htmlOnly = True
            doWhatif = False
            doProcheck = False
            doWattos = 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 entryId in entryList:
            project = Project.open( entryId, status='new' )
            self.assertTrue(project, 'Failed opening project: ' + entryId)

            ccpnFile = os.path.join(cingDirTestsData,"ccpn", entryId+".tgz")
            self.assertTrue(project.initCcpn(ccpnFolder=ccpnFile))
            self.assertTrue(project.save())
            self.assertFalse(project.validate(htmlOnly=htmlOnly,
                                              doProcheck = doProcheck,
                                              doWhatif=doWhatif,
                                              doWattos=doWattos,
                                               ))
#            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))
Esempio n. 55
0
    def test_shiftx(self):
        #        entryId = "1brv" # Small much studied PDB NMR entry
        #        entryId = "2hgh_1model"  RNA-protein complex.
        entryId = "1brv"
        #        entryId = "1tgq_1model" # withdrawn entry
        cingDirTmpTest = os.path.join(cingDirTmp, getCallerName())
        mkdirs(cingDirTmpTest)
        self.failIf(os.chdir(cingDirTmpTest),
                    msg="Failed to change to test directory for files: " +
                    cingDirTmpTest)

        project = Project(entryId)
        self.failIf(project.removeFromDisk())
        project = Project.open(entryId, status='new')
        cyanaFile = os.path.join(cingDirTestsData, "cyana",
                                 entryId + ".cyana.tgz")
        self.assertTrue(project.initCyana(cyanaFolder=cyanaFile))
        project.runShiftx()
Esempio n. 56
0
 def test_GetNextAvailableChainId(self):
     entryId = 'test'
     project = Project(entryId)
     self.failIf(project.removeFromDisk())
     project = Project.open(entryId, status='new')
     molecule = Molecule(name='moleculeName')
     project.appendMolecule(molecule)  # Needed for html.
     chainId = molecule.getNextAvailableChainId()
     self.assertEquals(chainId, Chain.defaultChainId)
     n = 26 * 2 + 10 + 1  # alpha numeric including an extra and lower cased.
     for _c in range(n):
         chainId = molecule.getNextAvailableChainId()
         self.assertTrue(molecule.addChain(chainId))
     nTdebug("Added %d chains to: %s" % (n, format(molecule)))
     self.assertEqual(len(molecule.allChains()), n)
Esempio n. 57
0
def updateProjectHtml(pdb_id, extraArgListStr):
    #    extraArgList = extraArgListStr.split()
    htmlOnly = True
    project = Project.open(pdb_id, status='old')
    nTmessage("Opened existing project")
    if not project:
        nTerror("Failed to init old project")
        return True
    # end if
    archive_id = getArchiveIdFromDirectoryName(os.getcwd())
    # Derives the related entry codes in PDB and BMRB.
    project.molecule.setArchiveId(archive_id)
    if True:  # DEFAULT: True
        nTmessage("Updating project html")
        #    project.runCingChecks(toFile=True, ranges=ranges)
        project.setupHtml()
        project.generateHtml(htmlOnly=htmlOnly)
        project.renderHtml()
    # end if
    project.save()
    nTmessage("Done with updateProjectHtml")