Exemplo 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()
Exemplo n.º 2
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()
Exemplo n.º 3
0
 def testRootPath(self):
     p = Project('1brv')
     self.assertEquals('./1brv.cing', p.rootPath('1brv')[0])
     self.assertEquals('1brv', p.rootPath('1brv')[1])
     nTmessage("hello")
     nTdebug(p.root)
Exemplo n.º 4
0
 def testRootPath(self):
     p = Project('1brv')
     self.assertEquals('./1brv.cing', p.rootPath('1brv')[0])
     self.assertEquals('1brv', p.rootPath('1brv')[1])
     nTmessage("hello")
     nTdebug(p.root)
Exemplo n.º 5
0
def upgradeProject2Json( name, restore  ):
    """Upgrade the project from project.xml to project.json file
    Convert several parameters to new Adict types
    """
    io.debug('upgradeToJson: restoring {0}\n', name)

    root, newName, ext = Project.rootPath(name)
    if not root:
        io.error('upgradeToJson: unable to open Project "{0}" because root is [{1}]\n', name, root)
        return None
    if not root.exists():
        io.error('upgradeToJson: unable to open Project "{0}" because root [{1}] was not found\n', name, root)
        return None
    #end if

    pfile = root / 'project.xml' # Name in all versions <= 1.0
    # Check if we find the xml file
    if pfile.exists():
        io.message('==> Upgrading cing project; please stand by\n')
        #GWV: 20140203: cannot do an update method() -> errors in partioning restraints. Do not understand
        pr = xmlTools.xML2obj(pfile)

        if pr is None:
            io.error('upgradeToJson: parsing from project file "{0}" failed\n', pfile)
            return None

        try:
            # <= 0.75 version have string
            pr.version = float(pr.version.strip('abcdefghijklmnopqrtsuvw ()!@#$%^&*').split()[0])
        except:
            pass

        # change to Time object
        pr.created = io.Time.fromString(pr.created)
        pr.lastSaved = io.Time(disk.modtime(pfile))

        # change types of names list
        for listName in 'moleculeNames peakListNames distanceListNames dihedralListNames rdcListNames'.split():
            #print 'listName>>',listName, (listName in pr)
            if listName in pr:
                pr[listName] = [n for n in pr[listName]]

        # update from old status type
        status = Adict()
        for key in constants.VALIDATION_KEYS:
            sdict = StatusDict(key)
            status[key] = sdict
            # if not isinstance(sdict, StatusDict):
            #     sdict = StatusDict(key)
            if key in pr.status:
                # print 'upgrade2json> key=', key
                # not certain if we get dict or NTdict; this circumvent unwanted keys of NTdict
                for k,v in pr.status[key].items():
                    #print 'upgrade2json>> k,v', k,v
                    sdict[k] = v
                #print '>>>\n', sdict.formatItems()
            #end if
        #end for

        #end for
        # update the status from old definitions;
        for (key, statusName) in [
                (constants.SHIFTX_KEY, 'shiftxStatus'),
                (constants.PROCHECK_KEY,'procheckStatus'),
                (constants.DSSP_KEY, 'dsspStatus'),
                (constants.WHATIF_KEY, 'whatifStatus'),
                (constants.WATTOS_KEY, 'wattosStatus'),
                (constants.VASCO_KEY, 'vascoStatus'),
                (constants.X3DNA_KEY, 'x3dnaStatus')
            ]:
            sdict = status[key]
            if statusName in pr:

                #print 'upgrade2json> statusName=', statusName

                # not certain if we get dict or NTdict; this circumvent unwanted keys of NTdict
                for k,v in pr[statusName].items():
                    #print 'upgrade2json>> k,v=', k,v
                    sdict[k] = v
                #print '>>>\n', sdict.formatItems()
            #end if
            #LEGACY names
            pr[statusName] = sdict
        #end for
        # update some fields if present
        for sdict in status.values():
            if 'molecule' in sdict and isinstance(sdict['molecule'], tuple):
                sdict['molecule'] = pid.Pid.new('Molecule:' + sdict['molecule'][0])
            if 'moleculeName' in sdict and isinstance(sdict['molecule'], tuple):
                sdict['molecule'] = pid.Pid.new('Molecule:' + sdict['moleculeName'][0])
                del sdict['moleculeName']
            if 'runVersion' in sdict:
                sdict['version'] = sdict['runVersion']
                del sdict['runVersion']
            if 'smlFile' in sdict:
                del sdict['smlFile']
#            sdict['date'] = io.Time(1360158182.7)  # Wed Feb  6 13:43:02 2013
            sdict['date'] = io.Time(pr.lastSaved) # make a copy because otherwise the json handler breaks
            sdict['version'] = 0.95  # old version
        #end for
        # make this the new status dict
        pr.status = status

        #print '>>>>>\n', pr.status.queeny.formatItems()

        pr._save2json()
        # have to make the directory because we have not yet fully initialised all directories at this stage
        pr._updateProjectPaths()
        disk.rename(pfile, pr.path() / cdefs.directories.version1 / 'project.xml' )
        #now we should be able to open it again
        return Project.open( name, status = constants.PROJECT_OLD, restore = restore )

    else:
        io.error('upgradeToJson: missing Project file "{0}"\n', pfile)
        return None