Пример #1
0
    def create(self, fileName, sizes, srcDataset=None, title=""):
        Dataset.createDataset(fileName, "", sizes, True)
        dataset = self.open(fileName, True)
        if srcDataset:
            nDim = len(sizes)
            nDimSrc = srcDataset.getNDim()
            for iDim in range(min(nDim, nDimSrc)):
                srcDataset.copyHeader(dataset, iDim)
            dataset.writeHeader()

        return dataset
Пример #2
0
    def genRNASecStrPeaks(self,
                          dataset,
                          listName="",
                          condition="sim",
                          scheme=""):
        self.setWidths([self.widthH, self.widthH])
        peakList = self.getPeakList(dataset, listName)

        if scheme == "" and dataset != None:
            if not isinstance(dataset, Dataset):
                dataset = Dataset.getDataset(dataset)
            self.setLabelScheme(dataset.getProperty("labelScheme"))
            scheme = dataset.getProperty("editScheme")
        if scheme == "":
            scheme = "aa"

#print(self.vienna)
        ss = SSGen(self.mol, self.vienna)
        ss.genRNAResidues()
        ss.pairTo()
        ss.secondaryStructGen()

        peakList.setSampleConditionLabel(condition)
        self.addRNASecStrPeaks(peakList, scheme)
        return peakList
Пример #3
0
    def genTOCSYPeaks(self,
                      dataset,
                      listName="",
                      condition="sim",
                      transfers=2):
        self.setWidths([self.widthH, self.widthH])
        if dataset != None and dataset != "":
            if not isinstance(dataset, Dataset):
                dataset = Dataset.getDataset(dataset)
            labelScheme = dataset.getProperty("labelScheme")
            self.setLabelScheme(labelScheme)
        peakList = self.getPeakList(dataset, listName)
        peakList.setSampleConditionLabel(condition)

        entities = self.getResiduesAndCompounds(self.mol)
        for entity in entities:
            cList = CouplingList()
            cList.generateCouplings(entity, 3, 2, transfers, 2)
            tLinks = cList.getTocsyLinks()
            for link in tLinks:
                a0 = link.getAtom(0)
                a1 = link.getAtom(1)
                shell = link.getShell()
                self.addPeak(peakList, [a0, a1])
        return peakList
Пример #4
0
    def createSub(self, fileName, nDim, srcDataset, title=""):
        if isinstance(srcDataset, basestring):
            srcDataset = nd.open(srcDataset, False)
        sizes = []
        nDimSrc = srcDataset.getNDim()
        if nDim > nDimSrc:
            raise Exception("New dataset has more dimensions than source")
        for iDim in range(nDim):
            sizes.append(srcDataset.getSize(iDim))

        Dataset.createDataset(fileName, "", sizes, True)
        dataset = self.open(fileName, True)
        for iDim in range(nDim):
            srcDataset.copyHeader(dataset, iDim)
        dataset.writeHeader()

        return dataset
Пример #5
0
def processEndSpectrum(line):
    global spectrumData
    global projectDir
    if 'pathname' in spectrumData:
        fileName = spectrumData['pathname'][0]
        fileName = os.path.join(projectDir, fileName)
        print 'path is', fileName
        if os.path.exists(fileName):
            dataset = Dataset(fileName, "", False, False)
Пример #6
0
 def getListName(self, dataset, tail="_gen"):
     if not isinstance(dataset, Dataset):
         dataset = Dataset.getDataset(dataset)
     dataName = dataset.getName()
     index = dataName.find(".")
     if index != -1:
         dataName = dataName[0:index]
     listName = dataName + tail
     return listName
Пример #7
0
 def getPeakList(self, dataset, listName):
     if (dataset == None or dataset == "") and listName != "":
         peakList = PeakList.get(listName)
     else:
         if listName == "":
             listName = self.getListName(dataset)
         if not isinstance(dataset, Dataset):
             dataset = Dataset.getDataset(dataset)
         peakList = peakgen.makePeakListFromDataset(listName, dataset)
     return peakList
Пример #8
0
 def setDims(self, dataset=None, dims=None):
     if dataset != None:
         if dims != None:
             dataObj = Dataset.getDataset(dataset)
             iDims = []
             for dim in dims:
                 if isinstance(dim, int):
                     iDims.append(dim)
                 else:
                     iDim = dataObj.getDim(dim)
                     iDims.append(iDim)
         self.cmd.setDims(dataset, iDims)
Пример #9
0
def compareFiles(dName1, dName2, threshold):
    dataset1 = Dataset(dName1, 'data1.nv', False)
    dataset2 = Dataset(dName2, 'data2.nv', False)
    iDim = 0

    sum = 0.0
    for (vec1, vec2) in izip(dataset1.vectors(iDim), dataset2.vectors(iDim)):
        vec1.softThreshold(threshold)
        vec2.softThreshold(threshold)
        vec3 = vec1 - vec2
        vec3.abs()
        sum += vec3.sum().getReal()
    return sum
Пример #10
0
def loadSaveFile(fileName, listName, aDataset=None):
    global peakListName
    global dataset
    global peakList
    global pMap
    peakList = None
    dataset = aDataset
    print pMap
    print 'dd1', dataset
    if dataset != None:
        print 'dd2', dataset
        if not isinstance(dataset, Dataset):
            dataset = Dataset.getDataset(dataset)
            print 'dd3', dataset
    print fileName, listName
    peakListName = listName
    with open(fileName, 'r') as f1:
        for line in f1:
            line = line.strip()
            processLine(line)
Пример #11
0
    def genHSQCPeaks(self, pType, dataset, listName="", condition="sim"):
        self.setWidths([self.widthH * 2, self.widthC])
        if dataset != None and dataset != "":
            if not isinstance(dataset, Dataset):
                dataset = Dataset.getDataset(dataset)
            labelScheme = dataset.getProperty("labelScheme")
            self.setLabelScheme(labelScheme)
        peakList = self.getPeakList(dataset, listName)
        peakList.setSampleConditionLabel(condition)
        atoms = self.mol.getAtoms("*.H*")
        for atom in atoms:
            sym = atom.getElementName()
            if sym == "H":
                if atom.isMethyl() and not atom.isFirstInMethyl():
                    continue
                parent = atom.getParent()
                if parent != None:
                    pSym = parent.getElementName()
                    if pType == pSym:
                        self.addPeak(peakList, [atom, parent])

        return peakList
Пример #12
0
    def genDistancePeaks(self,
                         dataset,
                         listName="",
                         condition="sim",
                         scheme="",
                         tol=5.0):
        self.setWidths([self.widthH, self.widthH])
        if dataset != None and dataset != "":
            if not isinstance(dataset, Dataset):
                dataset = Dataset.getDataset(dataset)
            labelScheme = dataset.getProperty("labelScheme")
            self.setLabelScheme(labelScheme)
            if scheme == "":
                scheme = dataset.getProperty("editScheme")
        if scheme == "":
            scheme = "aa"

        (d1Edited, d2Edited) = editingModes[scheme]
        peakList = self.getPeakList(dataset, listName)
        self.mol.selectAtoms("*.H*")
        protonPairs = self.mol.getDistancePairs(tol, False)
        for protonPair in protonPairs:
            dis = protonPair.getDistance()
            if dis > 4.0:
                volume = 0.2
            elif dis > 3.0:
                volume = 0.5
            else:
                volume = 1.0
            intensity = volume
            self.addProtonPairPeak(peakList, protonPair.getAtom1(),
                                   protonPair.getAtom2(), intensity, d1Edited,
                                   d2Edited)
            self.addProtonPairPeak(peakList, protonPair.getAtom2(),
                                   protonPair.getAtom1(), intensity, d1Edited,
                                   d2Edited)
        return peakList
Пример #13
0
 def get(self, datasetName):
     dataset = Dataset.getDataset(datasetName)
     return dataset
Пример #14
0
 def datasets(self):
     return Dataset.datasets()
Пример #15
0
 def names(self):
     return Dataset.names()
Пример #16
0
 def open(self, fileName, writable=False):
     dataset = Dataset(fileName, "", writable, False)
     return dataset
Пример #17
0
def doSim(datasetName,
          bmrbFileName=None,
          nSigs=20,
          sigRng=None,
          noise=0.00005,
          dataPars=None,
          delay=None,
          fp=0.5,
          frMul=None,
          offset=0.0,
          ph=0.0,
          pep=False,
          decayFile=None):
    if dataPars == None:
        dimSizes = [2048, 512]
        sfH = 600.0
        sf = [sfH, sfH * 0.101329118]
        sw = [3000.0, 3000.0]
        dLabels = ['H', 'N']
        dataPars = DatasetPars(dimSizes, sf, sw, dLabels)

    nDims = len(dataPars.dimSizes)
    dataPars.pseudoDims = [2]

    if bmrbFileName != None:
        shiftSets = loadBMRBShifts(bmrbFileName)
        signals = makeSignals(shiftSets)
    else:
        signals = makeEmptySignals(nSigs)

    if sigRng == None:
        sigRng = SignalRng(frMin=[6.0, 90.0],
                           frMax=[11.0, 125.0],
                           amp=0.01,
                           ampSd=0.002,
                           lw=[20, 18],
                           lwSd=[5, 4])

    randomizeSignals(signals, sigRng)
    center = findCenter(2, signals)
    center = [0.0, 0.0]
    fcenter = list(center)
    fcenter.append(1)
    #dataPars.setRef(fcenter)
    convertToHz(dataPars, signals, center)
    if not decayFile:
        createDataset(dataPars, datasetName)
        dataset = Dataset(datasetName, 'hsqc.nv', True)
        for plane in range(dataPars.dimSizes[2]):
            newSignals = decaySignal(signals, plane * 100, 0.003)
            addDatasetSignals(dataset, dataPars, datasetName, newSignals,
                              plane, noise, delay, fp, frMul, offset, ph, pep)
        values = [1.0] * dataPars.dimSizes[2]
    else:
        headValues, decayValues, planes = readDecayFile(decayFile)
        if planes != dataPars.dimSizes[2]:
            print "Changing size of dim 3 from", dataPars.dimSizes[
                2], "to", planes
            dataPars.dimSizes = dataPars.dimSizes[0:2] + [planes]
        createDataset(dataPars, datasetName)
        dataset = Dataset(datasetName, 'hsqc.nv', True)
        for plane in range(dataPars.dimSizes[2]):
            newSignals = applyDecay(signals, decayValues, plane)
            addDatasetSignals(dataset, dataPars, datasetName, newSignals,
                              plane, noise, delay, fp, frMul, offset, ph, pep)
        if headValues != []:
            values = headValues
            if "CPMG" in decayFile:
                values.insert(0, 0.0)
        else:
            values = [1.0] * dataPars.dimSizes[2]

    dataset.setValues(2, values)

    saveRefPars(dataset, dataPars)
Пример #18
0
def createDataset(dataPars, datasetName):
    dimSizeArray = jarray.array(dataPars.dimSizes, 'i')
    dataset = Dataset.createDataset(datasetName, 'hsqc.nv', dimSizeArray)
    dataset = Dataset(datasetName, 'hsqc.nv', True)
    for dim in range(dataPars.nDims):
        dataset.setSf(dim, dataPars.sf[dim])
        dataset.setSw(dim, dataPars.sw[dim])
        dataset.setLabel(dim, dataPars.dimLabels[dim])
        dataset.setRefValue(dim, dataPars.ref[dim])
        dataset.setRefPt(dim, dataPars.dimSizes[dim] / 2)
        dataset.syncPars(dim)
    if dataPars.nDims > 2:
        dataset.setComplex(2, False)
        dataset.setFreqDomain(2, False)
    dataset.close
Пример #19
0
    def genProteinPeaks(self, expType, dataset, listName="", condition="sim"):
        expType = expType.lower()
        anames = {}
        anames['hsqc'] = [['H', 0, 'N', 0]]
        anames['hncaco'] = [['H', 0, 'N', 0, 'C', 0],
                            ['H', 0, 'N', 0, 'C', -1]]
        anames['hnco'] = [['H', 0, 'N', 0, 'C', -1]]
        anames['hncoca'] = [['H', 0, 'N', 0, 'CA', -1]]
        anames['hncocacb'] = [['H', 0, 'N', 0, 'CB', -1],
                              ['H', 0, 'N', 0, 'CA', -1]]
        anames['hnca'] = [['H', 0, 'N', 0, 'CA', 0],
                          ['H', 0, 'N', 0, 'CA', -1]]
        anames['hncacb'] = [['H', 0, 'N', 0, 'CB', 0],
                            ['H', 0, 'N', 0, 'CB', -1],
                            ['H', 0, 'N', 0, 'CA', 0],
                            ['H', 0, 'N', 0, 'CA', -1]]

        self.refMode = False
        expValues = anames[expType]
        if not isinstance(dataset, Dataset):
            dataset = Dataset.getDataset(dataset)

        peakList = self.getPeakList(dataset, listName)
        peakList.setSampleConditionLabel(condition)
        nDim = peakList.getNDim()
        nucNames = []
        for i in range(nDim):
            if dataset == None:
                nucName = peakList.getSpectralDim(i).getDimName()[0]
            else:
                nucName = dataset.getNucleus(i).getName()
            nucNames.append(nucName)

        polymers = self.mol.getPolymers()
        for polymer in polymers:
            residues = polymer.getResidues()
            for iRes, aResidue in enumerate(residues):
                for expSet in expValues:
                    nAtoms = len(expSet) / 2
                    atoms = [None] * nAtoms
                    ok = True
                    for aName, dRes in zip(expSet[0::2], expSet[1::2]):
                        if not aName[0] in nucNames:
                            ok = False
                            break
                        if dRes == 0:
                            res = aResidue
                        elif dRes == -1:
                            res = aResidue.getPrevious()
                        elif dRes == 1:
                            res = aResidue.getNext()
                        else:
                            raise ValueError("dRes (" + str(dRes) +
                                             " is invalid")
                        if res == None:
                            ok = False
                            break
                        atom = res.getAtom(aName)
                        if atom == None:
                            ok = False
                            break
                        index = nucNames.index(aName[0])
                        atoms[index] = atom
                    if ok:
                        self.addPeak(peakList, atoms)
        return peakList