Пример #1
0
def averagineCalc(avgMass, charge = 1):

    elemList = ['H','C','N','O','S']
    numIsotopes = N.array([2, 2, 2, 3, 5])

    maxDim1 = numIsotopes.max()
    maxDim2 = len(elemList)

    elemMasses = N.array([[1.0078246,    2.0141021,    0,        0,    0],
    [12.0000000,     13.0033554,     0,         0,    0],
    [14.0030732,     15.0001088,     0,         0,    0],
    [15.9949141,     16.9991322,     17.9991616,     0,    0],
    [31.972070,     32.971456,     33.967866,     34,    35.967080]])

    elemAbundances = N.array([[0.99985,    0.00015,    0,        0,    0],
    [0.988930,    0.011070,     0,         0,    0],
    [0.996337,    0.003663,     0,         0,    0],
    [0.997590,    0.000374,    0.002036,     0,    0],
    [0.9502,    0.0075,        0.0421,     0,    0.0002]])

    avgDict = {}
    avgDict['H']=7.7583
    avgDict['C']=4.9384
    avgDict['N']=1.3577
    avgDict['O']=1.4773
    avgDict['S']=0.0417

    avgMassDict = {}#this is the averagine mass dictionary not the average mass!
    avgMassDict['H']=1.00794
    avgMassDict['C']=12.011
    avgMassDict['N']=14.00670
    avgMassDict['O']=15.99940
    avgMassDict['S']=32.06600

    avgMonomerMass = 111.1254

    #n = int(N.round(avgMass/avgMonomerMass))
    n = avgMass/avgMonomerMass

    modelComp = []
    modelComp.append(int(N.round(avgDict['H']*n)))
    modelComp.append(int(N.round(avgDict['C']*n)))
    modelComp.append(int(N.round(avgDict['N']*n)))
    modelComp.append(int(N.round(avgDict['O']*n)))
    modelComp.append(int(N.round(avgDict['S']*n)))

    modelMass = 0.0
    for i,elem in enumerate(elemList):
        modelMass+=avgMassDict[elem]*modelComp[i]

    actualMass = avgMonomerMass*n
    modelDev = actualMass - modelMass

    print "Actual Mass, Deviation: ", actualMass, modelDev

    if libmercuryOk:
        mercAns = LMI.mercury(modelComp, numIsotopes, elemMasses, elemAbundances, charge, 1e-3)
        if mercAns[0] == 0:
            return mercAns
Пример #2
0
def isoCalc(elemList, elemComp, charge = 0):
    '''
    interface to mercury calc to get user defined isotope patterns
    Limiting the maximum isotopes to be considered to 5
    '''
    try:

        if len(elemList)== 0 or len(elemComp) == 0:
            return False

        if len(elemList) != len(elemComp):
            return False

        maxIsotopes = 7
        numElements = len(elemList)
        numIsotopes = N.zeros(maxIsotopes, dtype = N.int)

        elemMasses = N.zeros((numElements, maxIsotopes))
        elemAbundances = N.zeros((numElements, maxIsotopes))

        for i,elem in enumerate(elemList):
            if elemDict.has_key(elem):
                tempIsos = elemDict[elem].isotopes
                tempOrder = []
                tempOrder = N.array(tempOrder)
                orderInd = tempOrder.argsort()
    #            print orderInd
    #            tempIsos = tempIsos[maxOrder]
                maxIso = len(tempIsos)
                if maxIso > maxIsotopes:
                    maxIso = maxIsotopes
                numIsotopes[i] = int(maxIso)
                for j in xrange(maxIso):
                    #each iso is a tuple that is the (nominal mass, isotope mass, isotope abundance)
                    iso = tempIsos[j]
    #                print elem, iso[1], iso[2]
                    elemMasses[i][j]=iso[1]
                    elemAbundances[i][j]=iso[2]
    except:
        return [False, None]
#    print elemList
#    print elemMasses
#    print elemAbundances
#    print numIsotopes

    if libmercuryOk:
        print "Libmercury OK"
        mercAns = LMI.mercury(elemComp, numIsotopes, elemMasses, elemAbundances, charge, 1e-3)
#        mercAns = LMI.mercury(modelComp, numIsotopes, elemMasses, elemAbundances, charge, 1e-3)
        if mercAns[0] == 0:
            return [True, scaleIsos(mercAns[1])]
    else:
        return [False, None]