Skip to content

Commit

Permalink
updated and corrected tests
Browse files Browse the repository at this point in the history
  • Loading branch information
picciama committed Nov 29, 2023
1 parent 7859893 commit 33e6a7c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions tests/unit_tests/data/spectrum_input.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
,MODIFIED_SEQUENCE_MSA,MASS_ANALYZER,PRECURSOR_CHARGE,INTENSITIES,MZ
0,MADC[UNIMOD:4]AL,ITMS,3,"[8.367374208919049, 2.518602603776224, 2.659845673210951, 4.299728173158516, 8.429437752326157, 0.7658791467979553, 8.687813740941493, 4.242274660314113, 0.8870952432832802, 4.313779684221713, 9.85999775062545, 7.063310047653008, 3.769344924086586, 0.34573944283315394, 9.230812630932526, 2.9032249506511487, 0.16896663233629594, 4.298758775170723, 7.217987502296315, 3.353297934806431, 4.631502162705368, 9.755216218486419, 2.1256480468357153, 5.008320012303572, 3.9299345929497087, 5.518371902352563, 9.678792427922913, 7.188332486612458, 3.575907979109255, 1.6198502512898438, 2.073756458495215, 8.542819672412879, 4.617939899870581, 4.551642363765419, 5.261255462309467, 3.0909922308333106]","[44.60418045, 44.83719672, 65.46789156, 65.74364211, 68.43836233, 68.5568945, 100.04084565, 101.06332082, 107.3093803, 120.28354647, 130.53598685, 132.44059902, 159.17067912, 160.41780244, 160.61696132, 182.38682974, 184.29107775, 185.52539476, 203.86638805, 204.69984021, 221.93538571, 229.01732765, 239.34301275, 240.40067089, 273.94746116, 274.54878787, 318.50472119, 330.1423962, 340.31803747, 362.56644913, 477.78429961, 478.88793184, 549.28001133, 549.89034434, 663.11748586, 678.75743273]"
1,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM,ITMS,2,"[1.4164248121239809,8.877522470499141,2.769929884985547,4.2262473778221485,0.11980708135825413,4.018845069231666,9.129723320200778,7.697861046532033,8.208623238448748,0.2639301805160499,9.27485048215434,9.46769208204482,7.557618808649943,3.6574758537198173,8.772023052259234,4.893487701564584,1.75783549921386,2.465661093837327,6.904189639036693,5.927126848082592,1.0850499436616545,5.054284934369222,9.153715686259892,9.131390705792223,4.105196269529302,4.05439827391873,6.5417126797862934,0.31361390940653044,5.146609177243445,4.288002600271125]","[45.161295710005085,51.54885296589418,66.59100232828412,76.46998818311636,88.9497931302318,94.96375607336665,132.96862467283384,132.54034379092417,132.55305878340636,138.0706414233357,141.0999927313521,150.82224511858934,175.92807415613515,181.80640760214433,197.77185605094982,207.40705810019213,220.12250893419375,225.6223314834844,263.84611569200774,263.30510318393493,263.41659790235036,270.02004034886886,272.7518249295351,282.0540723305553,306.8305400229241,313.4314960810718,328.9902378739003,337.98734285656167,351.0333742950934,357.17866493720095,394.91071186443645,394.92476647336974,394.2605513308279,400.76848201659664,404.0125835881873,412.387350512958,437.95367564389164,444.55922566802104,459.68647556806906,469.1467820469859,481.89981407197683,488.3253064884637,525.2095228333937,525.3922134061314,525.5337504706993,531.203711733911,534.4200648177631,543.4991269622365,569.6550041417343,575.8133534060477,591.0796459175361,600.5273208333838,612.5713968777383,618.9441927324988,656.2203894626525,657.1362539082139,657.082171156148,662.5487893264586,665.5395176208337,674.818637557056,699.9166783622037,706.620777331881,721.7521401423007,731.0699195248876,744.5279003979845,749.8527336716827,787.7409658294658,787.4801720786868,788.2320656600327,793.406320902931,796.29361892111,806.1776975914215,831.3221372145645,837.6570409232702,852.8402523367416,861.7960838094697,874.9184972270374,880.763422146188,918.9985345574634,918.5688863250335,918.6807659728639,924.6849083392635,928.1189570717835,936.9283785457288,962.2787187987577,968.4347641322878,983.9939215170773,993.0108377337374,1006.1669113852267,1012.6052471800037,1049.5219822351721,1050.0379828904424,1049.8348192064007,1055.7296672846323,1059.2780736381553,1067.7055229952107,1093.7747425184532,1099.3377993470767,1115.398218600843,1123.9713008676222,1137.632816939427,1143.4017201086865,1181.3407409495042,1181.2692327999941,1181.249650702033,1186.681867775009,1190.0384615136777,1198.8515830270944,1224.3700093191767,1230.3975243951559,1246.4090745955398,1255.6774540311935,1268.4419517888236,1274.3579746109313,1312.1193207244226,1312.1811014354405,1311.6469879473418,1317.7245065105624,1320.7616303725897,1329.8969043283748,1377.9054872054999,1386.8918935200213,1442.6515673868616,1443.1064266726273,1452.3955566891084,1460.5108215533644,1508.7594517706225,1517.1291788857693,1573.5867056668221,1573.7716562562962,1583.2119609851222,1592.111644078143,1639.392538650422,1648.673618965434,1705.0452374402644,1705.3227848374838,1714.323880681171,1723.111408219502,1770.9380486508123,1779.8536228159417,1836.2752798275599,1836.0630738971968,1844.9172338627804,1853.6735977638225,1901.8440972041199,1910.585010434536,1967.0956948390422,1966.8194437069674,1975.9609314719844,1985.2766000449305,2098.0234227672318,2116.317431295543,2228.7832057810197,2247.592389834701,2360.199275899176,2378.384390433377,2491.647799101034,2509.779214713572,2622.80841980401,2640.5814749246942,2753.44052053984,2771.1039877534827,2884.6781347038673,2902.1421208508036,3015.571665816316,3033.938677074293,3146.9298774773843,3164.43184409032,3277.8969636376964,3295.167880881916,3408.813608767307,3426.960576739998,3539.6522482081523,3557.5234870820505,3670.6156544143073,3689.11727078171,3801.5354429013455,3820.0536427641496,3932.6923292585666,3950.6436603255406]"
2,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM,ITMS,3,"[]","[]"
3,MM,ITMS,1,"[1.4164248121239809,8.877522470499141,2.769929884985547,4.2262473778221485]","[49.161295710005085,49.54885296589418,63.59100232828412,79.46998818311636]"
,MODIFIED_SEQUENCE_MSA,PEPTIDE_LENGTH,MASS_ANALYZER,PRECURSOR_CHARGE,INTENSITIES,MZ
0,MADC[UNIMOD:4]AL,6,ITMS,3,"[8.367374208919049, 2.518602603776224, 2.659845673210951, 4.299728173158516, 8.429437752326157, 0.7658791467979553, 8.687813740941493, 4.242274660314113, 0.8870952432832802, 4.313779684221713, 9.85999775062545, 7.063310047653008, 3.769344924086586, 0.34573944283315394, 9.230812630932526, 2.9032249506511487, 0.16896663233629594, 4.298758775170723, 7.217987502296315, 3.353297934806431, 4.631502162705368, 9.755216218486419, 2.1256480468357153, 5.008320012303572, 3.9299345929497087, 5.518371902352563, 9.678792427922913, 7.188332486612458, 3.575907979109255, 1.6198502512898438, 2.073756458495215, 8.542819672412879, 4.617939899870581, 4.551642363765419, 5.261255462309467, 3.0909922308333106]","[44.60418045, 44.83719672, 65.46789156, 65.74364211, 68.43836233, 68.5568945, 100.04084565, 101.06332082, 107.3093803, 120.28354647, 130.53598685, 132.44059902, 159.17067912, 160.41780244, 160.61696132, 182.38682974, 184.29107775, 185.52539476, 203.86638805, 204.69984021, 221.93538571, 229.01732765, 239.34301275, 240.40067089, 273.94746116, 274.54878787, 318.50472119, 330.1423962, 340.31803747, 362.56644913, 477.78429961, 478.88793184, 549.28001133, 549.89034434, 663.11748586, 678.75743273]"
1,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM,30,ITMS,2,"[1.4164248121239809,8.877522470499141,2.769929884985547,4.2262473778221485,0.11980708135825413,4.018845069231666,9.129723320200778,7.697861046532033,8.208623238448748,0.2639301805160499,9.27485048215434,9.46769208204482,7.557618808649943,3.6574758537198173,8.772023052259234,4.893487701564584,1.75783549921386,2.465661093837327,6.904189639036693,5.927126848082592,1.0850499436616545,5.054284934369222,9.153715686259892,9.131390705792223,4.105196269529302,4.05439827391873,6.5417126797862934,0.31361390940653044,5.146609177243445,4.288002600271125]","[45.161295710005085,51.54885296589418,66.59100232828412,76.46998818311636,88.9497931302318,94.96375607336665,132.96862467283384,132.54034379092417,132.55305878340636,138.0706414233357,141.0999927313521,150.82224511858934,175.92807415613515,181.80640760214433,197.77185605094982,207.40705810019213,220.12250893419375,225.6223314834844,263.84611569200774,263.30510318393493,263.41659790235036,270.02004034886886,272.7518249295351,282.0540723305553,306.8305400229241,313.4314960810718,328.9902378739003,337.98734285656167,351.0333742950934,357.17866493720095,394.91071186443645,394.92476647336974,394.2605513308279,400.76848201659664,404.0125835881873,412.387350512958,437.95367564389164,444.55922566802104,459.68647556806906,469.1467820469859,481.89981407197683,488.3253064884637,525.2095228333937,525.3922134061314,525.5337504706993,531.203711733911,534.4200648177631,543.4991269622365,569.6550041417343,575.8133534060477,591.0796459175361,600.5273208333838,612.5713968777383,618.9441927324988,656.2203894626525,657.1362539082139,657.082171156148,662.5487893264586,665.5395176208337,674.818637557056,699.9166783622037,706.620777331881,721.7521401423007,731.0699195248876,744.5279003979845,749.8527336716827,787.7409658294658,787.4801720786868,788.2320656600327,793.406320902931,796.29361892111,806.1776975914215,831.3221372145645,837.6570409232702,852.8402523367416,861.7960838094697,874.9184972270374,880.763422146188,918.9985345574634,918.5688863250335,918.6807659728639,924.6849083392635,928.1189570717835,936.9283785457288,962.2787187987577,968.4347641322878,983.9939215170773,993.0108377337374,1006.1669113852267,1012.6052471800037,1049.5219822351721,1050.0379828904424,1049.8348192064007,1055.7296672846323,1059.2780736381553,1067.7055229952107,1093.7747425184532,1099.3377993470767,1115.398218600843,1123.9713008676222,1137.632816939427,1143.4017201086865,1181.3407409495042,1181.2692327999941,1181.249650702033,1186.681867775009,1190.0384615136777,1198.8515830270944,1224.3700093191767,1230.3975243951559,1246.4090745955398,1255.6774540311935,1268.4419517888236,1274.3579746109313,1312.1193207244226,1312.1811014354405,1311.6469879473418,1317.7245065105624,1320.7616303725897,1329.8969043283748,1377.9054872054999,1386.8918935200213,1442.6515673868616,1443.1064266726273,1452.3955566891084,1460.5108215533644,1508.7594517706225,1517.1291788857693,1573.5867056668221,1573.7716562562962,1583.2119609851222,1592.111644078143,1639.392538650422,1648.673618965434,1705.0452374402644,1705.3227848374838,1714.323880681171,1723.111408219502,1770.9380486508123,1779.8536228159417,1836.2752798275599,1836.0630738971968,1844.9172338627804,1853.6735977638225,1901.8440972041199,1910.585010434536,1967.0956948390422,1966.8194437069674,1975.9609314719844,1985.2766000449305,2098.0234227672318,2116.317431295543,2228.7832057810197,2247.592389834701,2360.199275899176,2378.384390433377,2491.647799101034,2509.779214713572,2622.80841980401,2640.5814749246942,2753.44052053984,2771.1039877534827,2884.6781347038673,2902.1421208508036,3015.571665816316,3033.938677074293,3146.9298774773843,3164.43184409032,3277.8969636376964,3295.167880881916,3408.813608767307,3426.960576739998,3539.6522482081523,3557.5234870820505,3670.6156544143073,3689.11727078171,3801.5354429013455,3820.0536427641496,3932.6923292585666,3950.6436603255406]"
2,MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM,31,ITMS,3,"[]","[]"
3,MM,2,ITMS,1,"[1.4164248121239809,8.877522470499141,2.769929884985547,4.2262473778221485]","[49.161295710005085,49.54885296589418,63.59100232828412,79.46998818311636]"
16 changes: 8 additions & 8 deletions tests/unit_tests/test_fragments.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ class TestGetModifications:

def test_get_modifications(self):
"""Test get_modifications."""
assert fragments._get_modifications("ABC") == ({}, 1, "ABC")
assert fragments._get_modifications("ABC") == {}

def test_get_modifications_carbamidomethylation(self):
"""Test get_modifications."""
assert fragments._get_modifications("ABC[UNIMOD:4]") == ({2: 57.02146}, 1, "ABC")
assert fragments._get_modifications("ABC[UNIMOD:4]") == {2: 57.021464}

def test_get_modifications_tmt_tag(self):
"""Test get_modifications."""
assert fragments._get_modifications("[UNIMOD:737]-ABC[UNIMOD:4]") == ({0: 229.162932, 2: 57.02146}, 2, "ABC")
assert fragments._get_modifications("[UNIMOD:737]-ABC[UNIMOD:4]") == {-2: 229.162932, 2: 57.021464}

def test_get_modifications_tmtpro_tag(self):
"""Test get_modifications."""
assert fragments._get_modifications("[UNIMOD:2016]-ABC[UNIMOD:4]") == ({0: 304.207146, 2: 57.02146}, 2, "ABC")
assert fragments._get_modifications("[UNIMOD:2016]-ABC[UNIMOD:4]") == {-2: 304.207146, 2: 57.021464}


class TestComputeMasses(unittest.TestCase):
Expand Down Expand Up @@ -61,22 +61,22 @@ def test_compute_ion_masses_tmtpro(self):
def test_compute_peptide_masses(self):
"""Test computation of peptide masses with valid input."""
seq = "SEQUENC[UNIMOD:4]E"
self.assertEqual(fragments.compute_peptide_mass(seq), 1045.2561516699998)
self.assertEqual(fragments.compute_peptide_mass(seq), 1045.2561556699998)

def test_compute_peptide_masses_tmtpro(self):
"""Test computation of peptide masses with valid input and tmt tag."""
seq = "[UNIMOD:737]-SEQUENC[UNIMOD:4]E"
self.assertEqual(fragments.compute_peptide_mass(seq), 1274.41908367)
self.assertEqual(fragments.compute_peptide_mass(seq), 1274.41908767)

def test_compute_peptide_masses_with_invalid_syntax(self):
"""Negative testing of comuptation of peptide mass with unsupported syntax of mod string."""
seq = "SEQUEM(Ox.)CE"
self.assertRaises(AssertionError, fragments.compute_peptide_mass, seq)
self.assertRaises(KeyError, fragments.compute_peptide_mass, seq)

def test_compute_peptide_masses_with_invalid_mod(self):
"""Negative testing of computation of peptide mass with unknown modification in mod string."""
seq = "SEQUENC[UNIMOD:0]E"
self.assertRaises(AssertionError, fragments.compute_peptide_mass, seq)
self.assertRaises(KeyError, fragments.compute_peptide_mass, seq)


class TestMassTolerances(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/test_mod_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_internal_to_mod_masses(self):
"""Test internal with mods to internal without_mods."""
self.assertEqual(
mod.internal_to_mod_mass(["[UNIMOD:737]-ABC[UNIMOD:4]DEFGHK[UNIMOD:737]"]),
["[+229.162932]-ABC[+57.02146]DEFGHK[+229.162932]"],
["[+229.162932]-ABC[+57.021464]DEFGHK[+229.162932]"],
)

def test_proteomicsdb_to_internal(self):
Expand Down

0 comments on commit 33e6a7c

Please sign in to comment.