Exemplo n.º 1
0
def getCASP_NMR_DBMS():
    csvFileDir = os.path.join(baseDir, 'Overview')
    relationNames = glob1(csvFileDir, "*.csv")
    relationNames = [ relationName[:-4] for relationName in relationNames]
    dbms = DBMS()
    dbms.readCsvRelationList(relationNames, csvFileDir)
    return dbms
Exemplo n.º 2
0
def getCASP_NMR_DBMS():
    csvFileDir = os.path.join(baseDir, 'Overview')
    relationNames = glob1(csvFileDir, "*.csv")
    relationNames = [relationName[:-4] for relationName in relationNames]
    dbms = DBMS()
    dbms.readCsvRelationList(relationNames, csvFileDir)
    return dbms
Exemplo n.º 3
0
 def testDBMSread(self):
     csvFileDir = os.path.join(cingDirTestsData, "dbms", "Overview")
     relationNames = glob("%s/*.csv" % csvFileDir)
     # Truncate the extensions
     relationNames = [relationName[:-4] for relationName in relationNames]
     dbms = DBMS()
     self.assertFalse(dbms.readCsvRelationList(relationNames, csvFileDir))
Exemplo n.º 4
0
 def testDBMSread(self):
     csvFileDir = os.path.join(cingDirTestsData, "dbms", 'Overview')
     relationNames = glob("%s/*.csv" % csvFileDir)
     # Truncate the extensions
     relationNames = [relationName[:-4] for relationName in relationNames]
     dbms = DBMS()
     self.assertFalse(dbms.readCsvRelationList(relationNames, csvFileDir))
Exemplo n.º 5
0
def getCASD_NMR_DBMS():
    csvFileDir = os.path.join(baseDir, 'Overview')
    relationNames = glob1(csvFileDir, "*.csv")
    relationNames = [ relationName[:-4] for relationName in relationNames]
    if not relationNames:
        nTerror('Failed to read any relation from %s' % baseDir)
    dbms = DBMS()
    dbms.readCsvRelationList(relationNames, csvFileDir)
    return dbms
Exemplo n.º 6
0
def getCASD_NMR_DBMS():
    csvFileDir = os.path.join(baseDir, 'Overview')
    relationNames = glob1(csvFileDir, "*.csv")
    relationNames = [relationName[:-4] for relationName in relationNames]
    if not relationNames:
        nTerror('Failed to read any relation from %s' % baseDir)
    dbms = DBMS()
    dbms.readCsvRelationList(relationNames, csvFileDir)
    return dbms
Exemplo n.º 7
0
def getBmrbLinks():
    """ Returns None for failure
    Returns matches_many2one hash.
    """
    dbms = DBMS()
#    matchBmrbPdbDataDirLocal = os.path.join(cingRoot, matchBmrbPdbDataDir) # Needs to change to live resource as well.
    matchBmrbPdbDataDirLocal = matchBmrbPdbDir
    dbms.readCsvRelationList([ matchBmrbPdbTable ], matchBmrbPdbDataDirLocal)
    mTable = dbms.tables[matchBmrbPdbTable]
#    nTmessage("mTable:\n%s" % mTable.__str__(show_rows=False))
    matches_many2one = mTable.getHash(useSingleValueOfColumn=1) # hashes by first column to the next by default already.
#    nTmessage("Found %s matches from PDB to BMRB" % len(matches_many2one))
    return matches_many2one
Exemplo n.º 8
0
def getBmrbLinks():
    """ Returns None for failure
    Returns matches_many2one hash.
    """
    dbms = DBMS()
    #    matchBmrbPdbDataDirLocal = os.path.join(cingRoot, matchBmrbPdbDataDir) # Needs to change to live resource as well.
    matchBmrbPdbDataDirLocal = matchBmrbPdbDir
    dbms.readCsvRelationList([matchBmrbPdbTable], matchBmrbPdbDataDirLocal)
    mTable = dbms.tables[matchBmrbPdbTable]
    #    nTmessage("mTable:\n%s" % mTable.__str__(show_rows=False))
    matches_many2one = mTable.getHash(
        useSingleValueOfColumn=1
    )  # hashes by first column to the next by default already.
    #    nTmessage("Found %s matches from PDB to BMRB" % len(matches_many2one))
    return matches_many2one
Exemplo n.º 9
0
def getBmrbCsCounts():
    dbms = DBMS()
    bmrbCountTableName = 'BMRB_CS_counts'
    dbms.readCsvRelationList([bmrbCountTableName], os.path.join(cingDirData, 'NRG'))
    bmrbCountTable = dbms.tables[ bmrbCountTableName ]
    bmrbCountTable.convertColumn(0) # default is integer data type converting the read strings
    bmrbCountTable.convertColumn(2)
    bmrbCountTableProper = bmrbCountTable.toTable()
#        nTdebug("Found table: %r" % bmrbCountTableProper)
    bmrbCountMap = NTdict()
#        idxColumnKeyList = [0, 1, 2]
    idxColumnKeyList = []
    bmrbCountMap.appendFromTableGeneric(bmrbCountTableProper, *idxColumnKeyList)

    return bmrbCountMap
Exemplo n.º 10
0
def getNumberOfEntries():
    nTmessage("Getting overall number of entry count")

    if os.path.exists(psqlTmpCsvFile):
        nTdebug('Removing previous copy of %s' % psqlTmpCsvFile)
        os.unlink(psqlTmpCsvFile)
    # end if
    # without semi-colon
    sqlSelectCmd = "select count(*) from pdbj.brief_summary"
    # without semi-colon
    sqlCopyCmd = "COPY (%s) TO STDOUT WITH CSV HEADER" % sqlSelectCmd
    command = "psql -h %s --command='%s' pdbmlplus pdbj" % (PDBJ_DB_HOST,
                                                            sqlCopyCmd)
    nTdebug("command: [%s]" % command)
    psqlProgram = ExecuteProgram(command, redirectOutputToFile=psqlTmpCsvFile)
    exitCode = psqlProgram()
    if exitCode:
        nTerrorT("Failed to run psql program with command: [%s]" % command)
        return True
    # end if
    if not os.path.exists(psqlTmpCsvFile):
        nTerror('Csv file %s not found' % psqlTmpCsvFile)
        return True
    # end if
    if not os.path.getsize(psqlTmpCsvFile):
        nTerror('Csv file %s is empty' % psqlTmpCsvFile)
        return True
    # end if
    relationNames = [psqlTmpCsvFile]
    # Truncate the .csv extensions
    relationNames = [relationName[:-4] for relationName in relationNames]
    dbms = DBMS()
    if dbms.readCsvRelationList(relationNames):
        nTerror("Failed to read relation: %s" % str(relationNames))
        return True
    # end if
    entryCountTable = dbms.tables[relationNames[0]]
    #        nTdebug('\n'+str(entryCountTable))
    entryCountColumnName = entryCountTable.columnOrder[0]
    if entryCountColumnName != 'count':
        nTerrorT("Failed to find count column name from DB")
        return True
    # end if
    entryCountList = entryCountTable.getColumnByIdx(0)
    entryCount = entryCountList[0]
    nTmessage("Currently found %s number of entries in pdbmlplus" % entryCount)
    return entryCount
Exemplo n.º 11
0
def getNumberOfEntries():
    nTmessage("Getting overall number of entry count")

    if os.path.exists(psqlTmpCsvFile):
        nTdebug('Removing previous copy of %s' % psqlTmpCsvFile)
        os.unlink(psqlTmpCsvFile)
    # end if
    # without semi-colon
    sqlSelectCmd = "select count(*) from pdbj.brief_summary"
    # without semi-colon
    sqlCopyCmd = "COPY (%s) TO STDOUT WITH CSV HEADER" % sqlSelectCmd
    command = "psql -h %s --command='%s' pdbmlplus pdbj" % ( PDBJ_DB_HOST, sqlCopyCmd)
    nTdebug("command: [%s]" % command)
    psqlProgram = ExecuteProgram(command, redirectOutputToFile=psqlTmpCsvFile)
    exitCode = psqlProgram()
    if exitCode:
        nTerrorT("Failed to run psql program with command: [%s]" % command)
        return True
    # end if    
    if not os.path.exists( psqlTmpCsvFile ):
        nTerror('Csv file %s not found' % psqlTmpCsvFile)
        return True
    # end if
    if not os.path.getsize(psqlTmpCsvFile):
        nTerror('Csv file %s is empty' % psqlTmpCsvFile)
        return True
    # end if
    relationNames = [ psqlTmpCsvFile ]
    # Truncate the .csv extensions
    relationNames = [ relationName[:-4] for relationName in relationNames]
    dbms = DBMS()
    if dbms.readCsvRelationList(relationNames):
        nTerror("Failed to read relation: %s" % str(relationNames))
        return True
    # end if
    entryCountTable = dbms.tables[relationNames[0]]
#        nTdebug('\n'+str(entryCountTable))
    entryCountColumnName = entryCountTable.columnOrder[0]
    if entryCountColumnName != 'count':
        nTerrorT("Failed to find count column name from DB")
        return True
    # end if
    entryCountList = entryCountTable.getColumnByIdx(0)
    entryCount = entryCountList[0]
    nTmessage("Currently found %s number of entries in pdbmlplus" % entryCount)
    return entryCount
Exemplo n.º 12
0
def getBmrbCsCounts():
    dbms = DBMS()
    bmrbCountTableName = 'BMRB_CS_counts'
    dbms.readCsvRelationList([bmrbCountTableName],
                             os.path.join(cingDirData, 'NRG'))
    bmrbCountTable = dbms.tables[bmrbCountTableName]
    bmrbCountTable.convertColumn(
        0)  # default is integer data type converting the read strings
    bmrbCountTable.convertColumn(2)
    bmrbCountTableProper = bmrbCountTable.toTable()
    #        nTdebug("Found table: %r" % bmrbCountTableProper)
    bmrbCountMap = NTdict()
    #        idxColumnKeyList = [0, 1, 2]
    idxColumnKeyList = []
    bmrbCountMap.appendFromTableGeneric(bmrbCountTableProper,
                                        *idxColumnKeyList)

    return bmrbCountMap
Exemplo n.º 13
0
 def _test_writeCsvNRG(self):
     cingDirTmpTest = os.path.join( cingDirTmp, getCallerName() )
     mkdirs( cingDirTmpTest )
     self.failIf(os.chdir(cingDirTmpTest), msg =
         "Failed to change to test directory for files: " + cingDirTmpTest)
     myLoL = [ [0,1,2], [3,4,5] ]
     dbms = DBMS()
     r = Relation('mTable', dbms, columnList=['x', 'y'])
     r.fromLol(myLoL)
     r.writeCsvFile('myLoL')
Exemplo n.º 14
0
 def testDBMShashing(self):
     dbms = DBMS()
     mTable = Relation('mTable', dbms, columnList=['pdb_id', 'bmrb_id'])
     _pdbIdNewMany2OneList = mTable.getColumn('pdb_id')
     _bmrbIdNewMany2OneList = mTable.getColumn('bmrb_id')
     _pdbIdNewMany2OneList += '2kz0 2rop'.split()
     _bmrbIdNewMany2OneList += [16995, 11041]
     mTableHash = mTable.getHash()
     rowList = mTableHash['2rop']
     self.assertEqual(11041, rowList[1])
     nTdebug('\n' + str(mTable))
Exemplo n.º 15
0
    def _test_BMRBcounts(self):

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

        dbms = DBMS()
        bmrbCountTableName = 'BMRB_CS_counts'
        dbms.readCsvRelationList([bmrbCountTableName], os.path.join(cingDirData, 'NRG'))
        bmrbCountTable = dbms.tables[ bmrbCountTableName ]
        bmrbCountTable.convertColumn(0) # default is integer data type converting the read strings
        bmrbCountTable.convertColumn(2)
        bmrbCountTableProper = bmrbCountTable.toTable()
#        nTdebug("Found table: %r" % bmrbCountTableProper)
        bmrbCountMap = NTdict()
#        idxColumnKeyList = [0, 1, 2]
        idxColumnKeyList = []
        bmrbCountMap.appendFromTableGeneric(bmrbCountTableProper, *idxColumnKeyList)
        bmrb_id = 4020
        self.assertEqual( getDeepByKeysOrAttributes( bmrbCountMap, bmrb_id, '1H' ), 183)
        self.assertEqual( getDeepByKeysOrAttributes( bmrbCountMap, bmrb_id, '13C' ), 73)
        self.assertEqual( getDeepByKeysOrAttributes( bmrbCountMap, bmrb_id, '15N' ), None)