'Intensity': {0: 0.3624, 1: 0.040349999999999997, 2: 0.59724999999999995}, \ 'Formula': {0: 'H4C2O2', 1: 'H4C2O2', 2: 'H4C2O2'}, \ 'info2': {0: 'culture_1', 1: 'culture_1', 2: 'culture_1'}, \ 'Sample Name': {0: 'sample_1', 1: 'sample_1', 2: 'sample_1'}}) correc_inten_dict = {'sample_1': {(0, 1): np.array([ 0.0619]), (0, 0): np.array([ 0.2456]), \ (3, 0): np.array([ 0.0003]), (3, 1): np.array([ 0.0001]), (2, 1): np.array([ 0.0015]), \ (2, 0): np.array([ 0.0071]), (5, 0): np.array([ 0.]), (5, 1): np.array([ 0.60045]), \ (1, 0): np.array([ 0.06665]), (4, 1): np.array([ 0.]), (1, 1): np.array([ 0.0164]), \ (4, 0): np.array([ 0.])}} acetic_frag = Fragment('Acetic', 'H4C2O2', label_dict={'C13': 0}) fragments_dict = { 'Acetic_C13_0': iso.Infopacket(frag=acetic_frag, data={'sample_1': np.array([0.3624])}, unlabeled=True, name='Acetic') } label_list = [(0, 1), (0, 0), (3, 0), (3, 1), (2, 1), (2, 0), (5, 0), \ (5, 1), (1, 0), (4, 1), (1, 1), (4, 0)] def test_corr_matrix(): iso_tracer = 'C' with pytest.raises(KeyError): c_matrix = algo.corr_matrix(iso_tracer, no_atom_tracer, na_dict) def test_matrix_multiplication(): correction_matrix = [[0, 1], [2, 3]]
def test_arrange_fragments_by_mass(): assert algo.change_fragment_keys_to_mass(fragment_dict) == {(186.0, 79.0): iso.Infopacket(frag=[parent_frag_input, daughter_frag_input], data = data_input, unlabeled=False, name='2PG 185/79'), (185.0, 79.0): iso.Infopacket(frag=[parent_frag_unlabeled, daughter_frag_unlabeled], data = data_unlabel, unlabeled=True, name='2PG 185/79')}
def algorithms_yale_constants(): data_input = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 1967.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 1446.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 747.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 1926.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 1969.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 661.77 } data_unlabel = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 62610, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 58640, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 59950, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 62520, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 59690, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 57200 } corrected_data_input = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': -55.07, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': -456.52, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': -1214.13, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': -94., 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 43.33, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': -1211.27 } corrected_data_unlabel = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 64676.13, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 60575.12, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 61928.35, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 64583.16, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 61659.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 59087.6 } unlabeled_fragment = iso.insert_data_to_fragment_mass( Multiquantkey('2PG 185/79', 'O3P', '2PG 185/79', 'C3H6O7P'), 'C13_185.0_79.0', data_unlabel) input_fragment = iso.insert_data_to_fragment_mass( Multiquantkey('2PG 186/79', 'O3P', '2PG 185/79', 'C3H6O7P'), 'C13_186.0_79.0', data_input) parent_frag_input = input_fragment[('2PG 186/79_186.0', '2PG 186/79_79.0')][0][0] daughter_frag_input = input_fragment[('2PG 186/79_186.0', '2PG 186/79_79.0')][0][1] parent_frag_unlabeled = unlabeled_fragment[('2PG 185/79_185.0', '2PG 185/79_79.0')][0][0] daughter_frag_unlabeled = unlabeled_fragment[('2PG 185/79_185.0', '2PG 185/79_79.0')][0][1] fragment_dict = dict(unlabeled_fragment, **input_fragment) corrected_fragment_dict = { (186.0, 79.0): Infopacket( frag=['C3H6O7P', 'O3P'], data={ 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': -73.459999999999994, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': -473.81999999999999, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': -1231.96, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': -112.37, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 25.82, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': -1228.3 }, unlabeled=False, name='2PG 185/79'), (185.0, 79.0): Infopacket(frag=['C3H6O7P', 'O3P'], data={ 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 64694.910000000003, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 60592.709999999999, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 61946.339999999997, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 64601.919999999998, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 61677.68, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 59104.760000000002 }, unlabeled=True, name='2PG 185/79') } unlabeled_fragment_dhap = iso.insert_data_to_fragment_mass( Multiquantkey('DHAP 169/97', 'H2O4P', 'DHAP 169/97', 'C3H6O6P'), 'C13_169.0_97.0', { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 51670, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 52360, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 52540, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 56580, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 52580, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 58990 }) input_fragment_dhap = iso.insert_data_to_fragment_mass( Multiquantkey('DHAP 170/97', 'H2O4P', 'DHAP 169/97', 'C3H6O6P'), 'C13_170.0_97.0', { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 1292.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 901.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 1292.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 1468.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 1511.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 1946.67 }) corrected_data_unlabel_dhap = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 53390.610000000001, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 54103.589999999997, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 54289.580000000002, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 58464.110000000001, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 54330.910000000003, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 60954.370000000003 } corrected_data_input_dhap = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': -399.24000000000001, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': -821.89999999999998, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': -428.20999999999998, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': -382.83999999999997, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': -205.68000000000001, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 25.52 } parent_frag_input_dhap = input_fragment_dhap[('DHAP 170/97_170.0', 'DHAP 170/97_97.0')][0][0] daughter_frag_input_dhap = input_fragment_dhap[('DHAP 170/97_170.0', 'DHAP 170/97_97.0')][0][1] parent_frag_unlabeled_dhap = unlabeled_fragment_dhap[( 'DHAP 169/97_169.0', 'DHAP 169/97_97.0')][0][0] daughter_frag_unlabeled_dhap = unlabeled_fragment_dhap[( 'DHAP 169/97_169.0', 'DHAP 169/97_97.0')][0][1] corrected_fragment_dict_dhap = { (169.0, 97.0): iso.Infopacket( frag=[parent_frag_unlabeled_dhap, daughter_frag_unlabeled_dhap], data=corrected_data_unlabel_dhap, unlabeled=True, name='DHAP 169/97'), (170.0, 97.0): iso.Infopacket(frag=[parent_frag_input_dhap, daughter_frag_input_dhap], data=corrected_data_input_dhap, unlabeled=False, name='DHAP 169/97') } fragment_dict_dhap = dict(unlabeled_fragment_dhap, **input_fragment_dhap) metabolite_frag_dict = {'dhap': fragment_dict_dhap, '2pg': fragment_dict} corrected_metabolite_dict = { 'dhap': corrected_fragment_dict_dhap, '2pg': corrected_fragment_dict } return parent_frag_input, daughter_frag_input, \ fragment_dict, data_input, parent_frag_unlabeled, \ daughter_frag_unlabeled, data_unlabel, corrected_fragment_dict, metabolite_frag_dict, corrected_fragment_dict_dhap, corrected_fragment_dict
def algorithms_yale_constants(): data_input = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 1967.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 1446.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 747.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 1926.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 1969.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 661.77 } data_unlabel = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 62610, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 58640, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 59950, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 62520, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 59690, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 57200 } corrected_data_input = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': -55.07, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': -456.52, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': -1214.13, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': -94., 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 43.33, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': -1211.27 } corrected_data_unlabel = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 64676.13, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 60575.12, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 61928.35, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 64583.16, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 61659.77, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 59087.6 } unlabeled_fragment = iso.insert_data_to_fragment_mass( Multiquantkey('2PG 185/79', 'O3P', '2PG 185/79', 'C3H6O7P'), 'C13_185.0_79.0', data_unlabel) input_fragment = iso.insert_data_to_fragment_mass( Multiquantkey('2PG 186/79', 'O3P', '2PG 185/79', 'C3H6O7P'), 'C13_186.0_79.0', data_input) parent_frag_input = input_fragment[('2PG 186/79_186.0', '2PG 186/79_79.0')][0][0] daughter_frag_input = input_fragment[('2PG 186/79_186.0', '2PG 186/79_79.0')][0][1] parent_frag_unlabeled = unlabeled_fragment[('2PG 185/79_185.0', '2PG 185/79_79.0')][0][0] daughter_frag_unlabeled = unlabeled_fragment[('2PG 185/79_185.0', '2PG 185/79_79.0')][0][1] fragment_dict = dict(unlabeled_fragment, **input_fragment) corrected_fragment_dict = { (186.0, 79.0): iso.Infopacket(frag=[parent_frag_input, daughter_frag_input], data=corrected_data_input, unlabeled=False, name='2PG 185/79'), (185.0, 79.0): iso.Infopacket(frag=[parent_frag_unlabeled, daughter_frag_unlabeled], data=corrected_data_unlabel, unlabeled=True, name='2PG 185/79') } unlabeled_fragment_dhap = iso.insert_data_to_fragment_mass( Multiquantkey('DHAP 169/97', 'H2O4P', 'DHAP 169/97', 'C3H6O6P'), 'C13_169.0_97.0', { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 51670, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 52360, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 52540, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 56580, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 52580, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 58990 }) input_fragment_dhap = iso.insert_data_to_fragment_mass( Multiquantkey('DHAP 170/97', 'H2O4P', 'DHAP 169/97', 'C3H6O6P'), 'C13_170.0_97.0', { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 1292.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 901.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 1292.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 1468.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 1511.67, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 1946.67 }) corrected_data_unlabel_dhap = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': 53375.11, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': 54087.88, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': 54273.82, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': 58447.14, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': 54315.14, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 60936.67 } corrected_data_input_dhap = { 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 1)': -384.00, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 17)': -806.37, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 33)': -412.71, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 49)': -366.16, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 65)': -190.21, 'TA_SCS-ATP BCH_19May16_1June16.wiff (sample 81)': 42.83 } parent_frag_input_dhap = input_fragment_dhap[('DHAP 170/97_170.0', 'DHAP 170/97_97.0')][0][0] daughter_frag_input_dhap = input_fragment_dhap[('DHAP 170/97_170.0', 'DHAP 170/97_97.0')][0][1] parent_frag_unlabeled_dhap = unlabeled_fragment_dhap[( 'DHAP 169/97_169.0', 'DHAP 169/97_97.0')][0][0] daughter_frag_unlabeled_dhap = unlabeled_fragment_dhap[( 'DHAP 169/97_169.0', 'DHAP 169/97_97.0')][0][1] corrected_fragment_dict_dhap = { (169.0, 97.0): iso.Infopacket( frag=[parent_frag_unlabeled_dhap, daughter_frag_unlabeled_dhap], data=corrected_data_unlabel_dhap, unlabeled=True, name='DHAP 169/97'), (170.0, 97.0): iso.Infopacket(frag=[parent_frag_input_dhap, daughter_frag_input_dhap], data=corrected_data_input_dhap, unlabeled=False, name='DHAP 169/97') } fragment_dict_dhap = dict(unlabeled_fragment_dhap, **input_fragment_dhap) metabolite_frag_dict = {'dhap': fragment_dict_dhap, '2pg': fragment_dict} corrected_metabolite_dict = { 'dhap': corrected_fragment_dict_dhap, '2pg': corrected_fragment_dict } return parent_frag_input, daughter_frag_input, \ fragment_dict, data_input, parent_frag_unlabeled, \ daughter_frag_unlabeled, data_unlabel, corrected_fragment_dict, metabolite_frag_dict, corrected_fragment_dict_dhap, corrected_fragment_dict