Dateien nach "ILP" hochladen
Now ILP solver picks optimal combination of two different similarities and similarity can also be calcuated using the mean of similarity instead of the comparitive value
This commit is contained in:
+28
-13
@@ -232,10 +232,10 @@ CNMR2 = {
|
||||
|
||||
#Combination of methyl group and base purine rings from two papers
|
||||
CNMR3 = {
|
||||
1: ([153.1], [1]),
|
||||
1: ([154.9], [1]),
|
||||
2: ([150.0], [1]),
|
||||
3: ([108.1], [1]),
|
||||
4: ([154.9], [1]),
|
||||
4: ([153.1], [1]),
|
||||
5: ([142.6], [1]),
|
||||
6: ([29.3], [1]),
|
||||
7: ([33.9], [1]),
|
||||
@@ -268,7 +268,7 @@ def define_border_values(spectraref, spectranew, bin_width):
|
||||
shifts.append(shift[0])
|
||||
highest_ppm = math.ceil(max(shifts))
|
||||
lowest_ppm = math.floor(min(shifts))
|
||||
lowest_ppm = min(shifts) - bin_width/2 #Worse result. None of the previously wrong (except 0.6) become right
|
||||
#lowest_ppm = min(shifts) - bin_width/2 #Worse result. None of the previously wrong (except 0.6) become right
|
||||
return (lowest_ppm, highest_ppm)
|
||||
|
||||
def similarity_nmr(spectraref, spectranew, bin_width):
|
||||
@@ -294,21 +294,25 @@ def correction(spectra, corretionppm):
|
||||
return newspectra
|
||||
|
||||
def main():
|
||||
spectrumref = CNMR3
|
||||
spectrafalse = [CXANTHINE, C1XANTHINE, C3XANTHINE, C7XANTHINE, C1XANTHINE, C17XANTHINE, C37XANTHINE, C137XANTHINE]
|
||||
spectrumref = CCAFFEINE2
|
||||
spectra = [CXANTHINE, C1XANTHINE, C3XANTHINE, C7XANTHINE, C1XANTHINE, C17XANTHINE, C37XANTHINE, C137XANTHINE]
|
||||
spectranames = ["CXANTHINE", "C1XANTHINE", "C3XANTHINE", "C7XANTHINE", "C1XANTHINE", "C17XANTHINE", "C37XANTHINE", "C137XANTHINE"]
|
||||
likelihood = []
|
||||
for spectrumtrue in spectrafalse:
|
||||
for spectrumtrue in spectra:
|
||||
#errorlist = {}
|
||||
errorlist = []
|
||||
for correctionvalue in range(8, 12): #also tested 8.4, 8.37, 11
|
||||
#errorlist = []
|
||||
similaritybycorrection = []
|
||||
correctionvalues = range(8, 16) #also tested 8.4, 8.37, 11, 9.4 (for CNMR3)
|
||||
for correctionvalue in correctionvalues:
|
||||
spectrumrefcorrected = correction(spectrumref, correctionvalue) #CCAFFEINE 11 (klappt hier sehr gut) CCAFFEINE2 12 CPARAXANTHINE 10 CNMR1 9, 10 o 11 (sehr gut) CNMR2 10 o 11
|
||||
error = 0
|
||||
#Likelihood by number of higher similarity than all others.
|
||||
'''error = 0
|
||||
total = 0
|
||||
for spectrumfalse in spectrafalse:
|
||||
for spectrumfalse in spectra:
|
||||
positive = 0
|
||||
negative = 0
|
||||
bad_binwidth = []
|
||||
for i in np.arange(0.1, 3.9, 0.1): #Irgendwie hat 0.99999999999 einen Fehler den 1.0 nicht hat
|
||||
for i in np.arange(0.1, 2.6, 0.1): #successfull at max 3.9, but max 1.7 is lowest where nmr3 correctly classified, 1.6 increases likelihood of 3,7 over 1,7 even with 8.4 correction
|
||||
truesimilarity = similarity_nmr(spectrumtrue, spectrumrefcorrected, i)
|
||||
falsesimilarity = similarity_nmr(spectrumfalse, spectrumrefcorrected, i)
|
||||
#print(truesimilarity)
|
||||
@@ -324,8 +328,19 @@ def main():
|
||||
error += negative
|
||||
#errorlist[correctionvalue] = error
|
||||
errorlist.append(error)
|
||||
#print(min(range(len(errorlist)), key=errorlist.__getitem__))
|
||||
likelihood.append(round((total - min(errorlist))/total, 2))
|
||||
print(min(range(len(errorlist)), key=errorlist.__getitem__))
|
||||
likelihood.append(round((total - min(errorlist))/total, 2))'''
|
||||
#Likelihood by mean similarity
|
||||
#This method demonstrates the same problems as the other likelihood method
|
||||
similaritylist = []
|
||||
for i in np.arange(0.1, 3.9, 0.1):
|
||||
similaritylist.append(similarity_nmr(spectrumtrue, spectrumrefcorrected, i))
|
||||
similaritymean = sum(similaritylist) / len(similaritylist)
|
||||
similaritybycorrection.append(similaritymean)
|
||||
name = spectranames[spectra.index(spectrumtrue)]
|
||||
correctionindex = max(range(len(similaritybycorrection)), key=similaritybycorrection.__getitem__)
|
||||
print(f'{name}: {correctionindex} = {correctionvalues[correctionindex]}')
|
||||
likelihood.append(round(max(similaritybycorrection), 2))
|
||||
print(likelihood)
|
||||
'''for i in np.arange(0.01, 0.07, 0.01):
|
||||
print(f'Increment i: {i}')
|
||||
|
||||
Reference in New Issue
Block a user