Repository: matchms/matchms
Pull request #102 (2020-07-16 12:33:01)

Load from msp
Description from @efrain2010:
Created a function that allow users read .msp files and convert them into Spectrum objects

jspaaks: All the relevant parts have been implemented

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8de04a40..0d9c0cf3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Added
 
+- Read msp files to create Spectrum objects from it [#102](https://github.com/matchms/matchms/pull/102)
 - Peak weighting option for cosine score and modified cosine score [#96](https://github.com/matchms/matchms/issues/96)
 - Similarity score based on comparing parent masses [#79](https://github.com/matchms/matchms/pull/79)
 - Method for instantiating a spectrum from the metabolomics USI [#93](https://github.com/matchms/matchms/pull/93)
diff --git a/matchms/importing/__init__.py b/matchms/importing/__init__.py
index 8a4acc8d..37d5131c 100644
--- a/matchms/importing/__init__.py
+++ b/matchms/importing/__init__.py
@@ -1,12 +1,14 @@
 from .load_adducts import load_adducts
 from .load_from_json import load_from_json
 from .load_from_mgf import load_from_mgf
+from .load_from_msp import load_from_msp
 from .load_from_usi import load_from_usi
 
 
 __all__ = [
     "load_from_json",
     "load_from_mgf",
+    "load_from_msp",
     "load_from_usi",
     "load_adducts"
 ]
diff --git a/matchms/importing/load_from_msp.py b/matchms/importing/load_from_msp.py
new file mode 100644
index 00000000..10a83e58
--- /dev/null
+++ b/matchms/importing/load_from_msp.py
@@ -0,0 +1,95 @@
+from typing import Generator
+import numpy
+from ..Spectrum import Spectrum
+
+
+def parse_msp_file(filename: str) -> Generator[dict, None, None]:
+    """Read msp file and parse info in list of spectrum dictionaries."""
+
+    # Lists/dicts that will contain all params, masses and intensities of each molecule
+    params = {}
+    masses = []
+    intensities = []
+
+    # Peaks counter. Used to track and count the number of peaks
+    peakscount = 0
+
+    with open(filename, 'r') as f:
+        for line in f:
+            rline = line.rstrip()
+
+            if len(rline) == 0:
+                continue
+
+            if ':' in rline:
+                # Obtaining the params
+                splitted_line = rline.split(":", 1)
+                if splitted_line[0].lower() == 'comments':
+                    # Obtaining the parameters inside the comments index
+                    for s in splitted_line[1][2:-1].split('" "'):
+                        splitted_line = s.split("=", 1)
+                        if splitted_line[0].lower() in params.keys() and splitted_line[0].lower() == 'smiles':
+                            params[splitted_line[0].lower()+"_2"] = splitted_line[1].strip()
+                        else:
+                            params[splitted_line[0].lower()] = splitted_line[1].strip()
+                else:
+                    params[splitted_line[0].lower()] = splitted_line[1].strip()
+            else:
+                # Obtaining the masses and intensities
+                peakscount += 1
+
+                splitted_line = rline.split(" ")
+
+                masses.append(float(splitted_line[0]))
+                intensities.append(float(splitted_line[1]))
+
+                # Obtaining the masses and intensities
+                if int(params['num peaks']) == peakscount:
+                    peakscount = 0
+                    yield {
+                        'params': (params),
+                        'm/z array': numpy.array(masses),
+                        'intensity array': numpy.array(intensities)
+                    }
+
+                    params = {}
+                    masses = []
+                    intensities = []
+
+
+def load_from_msp(filename: str) -> Generator[Spectrum, None, None]:
+    """
+    MSP file to a :py:class:`~matchms.Spectrum.Spectrum` objects
+    Function that reads a .msp file and converts the info
+    in :py:class:`~matchms.Spectrum.Spectrum` objects.
+
+    Args:
+        filename: path of the msp file
+
+    Yields:
+        Yield a spectrum object with the data of the msp file
+
+
+    Example:
+
+    .. code-block:: python
+
+        from matchms.importing import load_from_msp
+
+        # Download msp file from MassBank of North America repository at https://mona.fiehnlab.ucdavis.edu/
+
+        spectrum = next(load_from_msp("MoNA-export-GC-MS-first10.msp"))
+    """
+
+    for spectrum in parse_msp_file(filename):
+        metadata = spectrum.get("params", None)
+        mz = spectrum["m/z array"]
+        intensities = spectrum["intensity array"]
+
+        # Sort by mz (if not sorted already)
+        if not numpy.all(mz[:-1] <= mz[1:]):
+            idx_sorted = numpy.argsort(mz)
+            mz = mz[idx_sorted]
+            intensities = intensities[idx_sorted]
+
+        yield Spectrum(mz=mz, intensities=intensities, metadata=metadata)


Test patch:
diff --git a/tests/MoNA-export-GC-MS-first10.msp b/tests/MoNA-export-GC-MS-first10.msp
new file mode 100644
index 00000000..ae465de8
--- /dev/null
+++ b/tests/MoNA-export-GC-MS-first10.msp
@@ -0,0 +1,603 @@
+Name: 1-NITROPYRENE
+Synonym: 1-NITROPYRENE
+DB#: JP000001
+InChIKey: ALRLPDGCPYIVHP-UHFFFAOYSA-N
+MW: 247.063328528
+Formula: C16H9NO2
+PrecursorMZ: 0
+Comments: "accession=JP000001" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=247.06333" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335755" "SMILES=[O-1][N+1](=O)c(c4)c(c1)c(c3c4)c(c2cc3)c(ccc2)c1" "InChI=InChI=1S/C16H9NO2/c18-17(19)14-9-7-12-5-4-10-2-1-3-11-6-8-13(14)16(12)15(10)11/h1-9H" "molecular formula=C16H9NO2" "total exact mass=247.063328528" "SMILES=[H]C=1C([H])=C2C([H])=C([H])C3=C([H])C([H])=C(C=4C([H])=C([H])C(C1[H])=C2C34)N(=O)=O" "InChIKey=ALRLPDGCPYIVHP-UHFFFAOYSA-N"
+Num Peaks: 75
+51 2.66
+55 8
+57 7.33
+58 1.33
+59 1.33
+60 14
+61 1.33
+62 3.33
+63 3.33
+66 1.33
+68 8.66
+70 2
+72 5.33
+73 7.33
+74 3.33
+75 2.66
+76 2
+78 1.33
+80 4
+81 2
+82 1.33
+83 3.33
+86 12.66
+87 8.66
+92 2
+93 10
+94 6
+98 14.66
+99 83.33
+100 60.66
+104 4
+107 1.33
+108 1.33
+110 3.33
+112 1.33
+113 1.33
+115 1.33
+116 1.33
+120 1.33
+122 4
+123 2.66
+124 2.66
+125 2
+126 1.33
+134 1.33
+135 2
+137 1.33
+147 1.33
+149 2
+150 4.66
+151 3.33
+159 2
+162 2
+163 2.66
+173 2
+174 8.66
+175 4.66
+177 2
+187 5.33
+188 4.66
+189 56.66
+190 12
+191 16.66
+198 10.66
+199 9.33
+200 72.66
+201 99.99
+202 16
+203 1.33
+207 1.33
+214 1.33
+217 25.33
+218 5.33
+247 52.66
+248 10.16
+
+
+Name: 2,4-DINITROPHENOL
+Synonym: 2,4-DINITROPHENOL
+DB#: JP000002
+InChIKey: UFBJCMHMOXMLKC-UHFFFAOYSA-N
+MW: 184.01202122799998
+Formula: C6H4N2O5
+PrecursorMZ: 0
+Comments: "accession=JP000002" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=184.01202" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335764" "SMILES=[O-1][N+1](=O)c(c1)cc([N+1]([O-1])=O)c(O)c1" "InChI=InChI=1S/C6H4N2O5/c9-6-2-1-4(7(10)11)3-5(6)8(12)13/h1-3,9H" "molecular formula=C6H4N2O5" "total exact mass=184.01202122799998" "SMILES=[H]OC1=C([H])C([H])=C(C([H])=C1N(=O)=O)N(=O)=O" "InChIKey=UFBJCMHMOXMLKC-UHFFFAOYSA-N"
+Num Peaks: 64
+51 27.22
+52 19.9
+53 61.8
+54 6.76
+55 13.95
+56 3.86
+57 11.52
+60 6.43
+61 13.38
+62 36.19
+63 61.37
+64 26.2
+65 6.74
+66 5.1
+67 7.43
+68 10.32
+69 29.16
+70 5.53
+71 6.11
+73 4.14
+74 3.92
+75 3.49
+76 4.33
+77 6.21
+78 5.1
+79 35.07
+80 9.85
+81 16
+82 5.37
+83 6.13
+84 2.96
+85 3
+90 12.01
+91 53.25
+92 28.32
+93 18.25
+94 3.51
+95 6.41
+96 5.43
+97 5.12
+98 2.43
+105 3.76
+106 6.35
+107 38.97
+108 7.11
+109 3.98
+111 2.63
+120 2.12
+121 4.45
+122 4
+123 3.14
+126 2.12
+136 2.77
+137 3.14
+138 3.55
+149 4.12
+153 4.02
+154 39.3
+155 3.16
+168 3.29
+183 3.26
+184 99.99
+185 8.17
+186 1.34
+
+
+Name: 3,4-DICHLOROPHENOL
+Synonym: 3,4-DICHLOROPHENOL
+DB#: JP000003
+InChIKey: WDNBURPWRNALGP-UHFFFAOYSA-N
+MW: 161.963920108
+Formula: C6H4Cl2O
+PrecursorMZ: 0
+Comments: "accession=JP000003" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=161.96392" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335820" "SMILES=Oc(c1)cc(Cl)c(Cl)c1" "InChI=InChI=1S/C6H4Cl2O/c7-5-2-1-4(9)3-6(5)8/h1-3,9H" "molecular formula=C6H4Cl2O" "total exact mass=161.963920108" "SMILES=[H]OC1=C([H])C([H])=C(Cl)C(Cl)=C1[H]" "InChIKey=WDNBURPWRNALGP-UHFFFAOYSA-N"
+Num Peaks: 36
+51 2.25
+53 6.4
+60 4.13
+61 9.78
+62 20.36
+63 32.41
+64 5.58
+71 2.16
+72 8.31
+73 13.57
+74 6.23
+75 5.23
+81 8.28
+82 5.27
+83 2.81
+91 2.06
+97 6.25
+98 25.55
+99 33.74
+100 9.84
+101 12.32
+107 2.31
+109 2.08
+126 7.67
+127 3.67
+128 2.81
+133 5.09
+134 7.44
+135 3.61
+136 4.75
+161 3.6
+162 99.99
+163 8.7
+164 62.28
+165 4.54
+166 9.78
+
+
+Name: 2,5-DICHLOROPHENOL
+Synonym: 2,5-DICHLOROPHENOL
+DB#: JP000004
+InChIKey: RANCECPPZPIPNO-UHFFFAOYSA-N
+MW: 161.963920108
+Formula: C6H4Cl2O
+PrecursorMZ: 0
+Comments: "accession=JP000004" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=161.96392" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335825" "SMILES=Oc(c1)c(Cl)ccc(Cl)1" "InChI=InChI=1S/C6H4Cl2O/c7-4-1-2-5(8)6(9)3-4/h1-3,9H" "molecular formula=C6H4Cl2O" "total exact mass=161.963920108" "SMILES=[H]OC1=C([H])C(Cl)=C([H])C([H])=C1Cl" "InChIKey=RANCECPPZPIPNO-UHFFFAOYSA-N"
+Num Peaks: 44
+51 5.05
+52 2.29
+53 22.87
+59 3.69
+60 16.58
+61 33.26
+62 62.1
+63 99.99
+64 11.61
+65 2.73
+66 4.11
+71 2.98
+72 12.03
+73 32.28
+74 12.69
+75 11.42
+81 6.65
+82 4.64
+83 3.82
+84 3.02
+85 2.81
+87 2.86
+89 2.17
+90 2.05
+91 6.28
+96 3.57
+97 15.64
+98 39
+99 33.72
+100 13.84
+101 10.87
+126 9.01
+127 3.11
+128 3.25
+133 6.28
+134 4.28
+135 4.21
+136 2.59
+161 11.74
+162 89.04
+163 12.37
+164 52.89
+165 4.62
+166 8.78
+
+
+Name: 2,6-DICHLOROPHENOL
+Synonym: 2,6-DICHLOROPHENOL
+DB#: JP000005
+InChIKey: HOLHYSJJBXSLMV-UHFFFAOYSA-N
+MW: 161.963920108
+Formula: C6H4Cl2O
+PrecursorMZ: 0
+Comments: "accession=JP000005" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=161.96392" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335848" "SMILES=Clc(c1)c(O)c(Cl)cc1" "InChI=InChI=1S/C6H4Cl2O/c7-4-2-1-3-5(8)6(4)9/h1-3,9H" "molecular formula=C6H4Cl2O" "total exact mass=161.963920108" "SMILES=[H]OC=1C(Cl)=C([H])C([H])=C([H])C1Cl" "InChIKey=HOLHYSJJBXSLMV-UHFFFAOYSA-N"
+Num Peaks: 33
+53 7.25
+60 3
+61 8.88
+62 17.84
+63 70.92
+64 8.02
+65 2.01
+72 5.48
+73 12.35
+74 4.63
+75 4.81
+81 6.73
+82 4.37
+83 2.09
+91 3.83
+97 7.27
+98 34.04
+99 15.04
+100 13.17
+101 4.37
+107 2.61
+125 2.01
+126 33.42
+127 3.34
+128 11.41
+133 3.34
+135 2.17
+161 2.35
+162 99.99
+163 8.23
+164 63.43
+165 4.35
+166 9.91
+
+
+Name: 2,3-DICHLOROPHENOL
+Synonym: 2,3-DICHLOROPHENOL
+DB#: JP000006
+InChIKey: UMPSXRYVXUPCOS-UHFFFAOYSA-N
+MW: 161.963920108
+Formula: C6H4Cl2O
+PrecursorMZ: 0
+Comments: "accession=JP000006" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=161.96392" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335870" "SMILES=Oc(c1)c(Cl)c(Cl)cc1" "InChI=InChI=1S/C6H4Cl2O/c7-4-2-1-3-5(9)6(4)8/h1-3,9H" "molecular formula=C6H4Cl2O" "total exact mass=161.963920108" "SMILES=[H]OC=1C([H])=C([H])C([H])=C(Cl)C1Cl" "InChIKey=UMPSXRYVXUPCOS-UHFFFAOYSA-N"
+Num Peaks: 42
+51 4.43
+53 10.39
+60 9.21
+61 24.93
+62 43.19
+63 99.99
+64 12.57
+65 4.81
+66 3.39
+71 3.67
+72 15.34
+73 25.07
+74 11.84
+75 8.79
+81 4.78
+82 3.25
+83 2.63
+84 3.87
+85 2.49
+87 5.09
+89 2.21
+91 6.02
+96 3.11
+97 12.05
+98 35.88
+99 22.09
+100 13.5
+101 6.26
+107 3.33
+109 2.73
+125 3.11
+126 59.16
+127 5.61
+128 19.32
+133 5.33
+135 2.84
+161 2.52
+162 68.96
+163 6.51
+164 51.64
+165 2.9
+166 7.58
+
+
+Name: 2,4-DICHLOROPHENOL
+Synonym: 2,4-DICHLOROPHENOL
+DB#: JP000007
+InChIKey: HFZWRUODUSTPEG-UHFFFAOYSA-N
+MW: 161.963920108
+Formula: C6H4Cl2O
+PrecursorMZ: 0
+Comments: "accession=JP000007" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=161.96392" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210335864" "SMILES=Oc(c1)c(Cl)cc(Cl)c1" "InChI=InChI=1S/C6H4Cl2O/c7-4-1-2-6(9)5(8)3-4/h1-3,9H" "molecular formula=C6H4Cl2O" "total exact mass=161.963920108" "SMILES=[H]OC1=C([H])C([H])=C(Cl)C([H])=C1Cl" "InChIKey=HFZWRUODUSTPEG-UHFFFAOYSA-N"
+Num Peaks: 37
+51 3.07
+53 12.34
+60 6.21
+61 19.31
+62 35.08
+63 99.99
+64 10.24
+66 2.25
+71 3.05
+72 10.59
+73 19.52
+74 8.59
+75 6.44
+81 6.82
+82 4.45
+83 2.77
+84 2.03
+91 2.34
+96 3.78
+97 31.79
+98 38.03
+99 21.59
+100 13.06
+101 4.67
+125 4.82
+126 20.32
+127 3.76
+128 7.38
+133 4.02
+134 2.72
+135 2.64
+161 19.22
+162 94.19
+163 15.34
+164 55.32
+165 5.54
+166 9.19
+
+
+Name: 3,5-DICHLOROPHENOL
+Synonym: 3,5-DICHLOROPHENOL
+DB#: JP000008
+InChIKey: VPOMSPZBQMDLTM-UHFFFAOYSA-N
+MW: 161.963920108
+Formula: C6H4Cl2O
+PrecursorMZ: 0
+Comments: "accession=JP000008" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=161.96392" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210336053" "SMILES=Oc(c1)cc(Cl)cc(Cl)1" "InChI=InChI=1S/C6H4Cl2O/c7-4-1-5(8)3-6(9)2-4/h1-3,9H" "molecular formula=C6H4Cl2O" "total exact mass=161.963920108" "SMILES=[H]OC=1C([H])=C(Cl)C([H])=C(Cl)C1[H]" "InChIKey=VPOMSPZBQMDLTM-UHFFFAOYSA-N"
+Num Peaks: 32
+51 1.24
+53 4.19
+60 3.61
+61 8.59
+62 16.38
+63 31.53
+64 4.94
+72 4.88
+73 10.01
+74 4.53
+75 3.92
+81 6.85
+82 4.37
+83 2.46
+97 7.3
+98 27.86
+99 28.43
+100 10.31
+101 9.88
+126 8.1
+127 4.51
+128 3.3
+133 4.08
+134 6.58
+135 2.96
+136 4.15
+161 3.31
+162 99.99
+163 8.57
+164 60.06
+165 4.43
+166 9.68
+
+
+Name: 2,4,5-TRICHLOROPHENOL
+Synonym: 2,4,5-TRICHLOROPHENOL
+DB#: JP000009
+InChIKey: LHJGJYXLEPZJPM-UHFFFAOYSA-N
+MW: 195.924947756
+Formula: C6H3Cl3O
+PrecursorMZ: 0
+Comments: "accession=JP000009" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=195.92495" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210336033" "SMILES=Oc(c1)c(Cl)cc(Cl)c(Cl)1" "InChI=InChI=1S/C6H3Cl3O/c7-3-1-5(9)6(10)2-4(3)8/h1-2,10H" "molecular formula=C6H3Cl3O" "total exact mass=195.924947756" "SMILES=[H]OC1=C([H])C(Cl)=C(Cl)C([H])=C1Cl" "InChIKey=LHJGJYXLEPZJPM-UHFFFAOYSA-N"
+Num Peaks: 65
+51 2.58
+53 14.73
+59 2.03
+60 12.75
+61 30.62
+62 36.79
+63 19.11
+64 2.15
+65 5.23
+66 13.42
+67 7.46
+69 2.46
+71 6.55
+72 13.85
+73 16.02
+74 7.55
+75 4.47
+79 2.34
+80 8.06
+81 5.21
+82 3.22
+83 7.1
+84 6.05
+85 6.38
+86 2.53
+87 3.44
+89 1.93
+95 3.8
+96 33.63
+97 67.27
+98 25.02
+99 31.7
+100 5.86
+106 2.03
+107 8.66
+108 3.94
+109 6.55
+131 12.51
+132 48.06
+133 32
+134 33.42
+135 18.37
+136 6.55
+137 2.96
+149 6.48
+151 3.39
+160 10.69
+161 4.76
+162 10.76
+163 3.58
+164 3.61
+167 4.06
+169 3.89
+177 4.76
+179 2.94
+192 6.69
+194 4.64
+195 6.79
+196 99.99
+197 11.45
+198 92.58
+199 7.82
+200 29.54
+201 2.08
+202 3.15
+
+
+Name: 2,4,6-TRICHLOROPHENOL
+Synonym: 2,4,6-TRICHLOROPHENOL
+DB#: JP000010
+InChIKey: LINPIYWFGCPVIE-UHFFFAOYSA-N
+MW: 195.924947756
+Formula: C6H3Cl3O
+PrecursorMZ: 0
+Comments: "accession=JP000010" "author=KOGA M, UNIV. OF OCCUPATIONAL AND ENVIRONMENTAL HEALTH" "license=CC BY-NC-SA" "exact mass=195.92495" "instrument=VARIAN MAT-44" "instrument type=EI-B" "ms level=MS1" "ionization energy=70 eV" "ion type=[M]+*" "ionization mode=positive" "Last Auto-Curation=1495210336053" "SMILES=Clc(c1)cc(Cl)c(O)c(Cl)1" "InChI=InChI=1S/C6H3Cl3O/c7-3-1-4(8)6(10)5(9)2-3/h1-2,10H" "molecular formula=C6H3Cl3O" "total exact mass=195.924947756" "SMILES=[H]OC=1C(Cl)=C([H])C(Cl)=C([H])C1Cl" "InChIKey=LINPIYWFGCPVIE-UHFFFAOYSA-N"
+Num Peaks: 66
+53 14.63
+55 2.49
+57 2.2
+60 12.21
+61 32.06
+62 42.22
+63 36.9
+64 4.32
+65 8.43
+66 23
+67 12.65
+68 2.71
+71 6.78
+72 13.68
+73 17.64
+74 8.84
+75 5.57
+80 9.94
+81 8.84
+82 4.21
+83 8.62
+84 6.16
+85 5.83
+87 3.92
+89 2.2
+90 2.89
+91 2.09
+95 4.84
+96 34.11
+97 70.76
+98 39.72
+99 38.18
+100 10.63
+101 2.64
+106 2.45
+107 9.09
+108 3.77
+109 7.22
+111 2.23
+125 3.44
+126 8.91
+127 2.05
+128 3.52
+131 18.48
+132 57.96
+133 22.12
+134 40.71
+135 10.45
+136 7.81
+160 31.84
+161 5.2
+162 50.47
+163 5.2
+164 22.81
+166 5.57
+167 4.1
+168 2.56
+169 3.63
+195 3.59
+196 99.99
+197 9.68
+198 91.34
+199 7.07
+200 28.42
+201 2.09
+202 3.04
+
diff --git a/tests/test_load_from_msp.py b/tests/test_load_from_msp.py
new file mode 100644
index 00000000..3ca930d3
--- /dev/null
+++ b/tests/test_load_from_msp.py
@@ -0,0 +1,21 @@
+import os
+import numpy
+from matchms.importing import load_from_msp
+
+
+def test_load_from_msp():
+    """Test parse of msp file to sprectum objects"""
+
+    module_root = os.path.join(os.path.dirname(__file__), "..")
+    spectrums_file = os.path.join(module_root, "tests", "MoNA-export-GC-MS-first10.msp")
+    spectrum = load_from_msp(spectrums_file)
+
+    expected_inchikey = numpy.array([
+        "ALRLPDGCPYIVHP-UHFFFAOYSA-N", "UFBJCMHMOXMLKC-UHFFFAOYSA-N", "WDNBURPWRNALGP-UHFFFAOYSA-N",
+        "RANCECPPZPIPNO-UHFFFAOYSA-N", "HOLHYSJJBXSLMV-UHFFFAOYSA-N", "UMPSXRYVXUPCOS-UHFFFAOYSA-N",
+        "HFZWRUODUSTPEG-UHFFFAOYSA-N", "VPOMSPZBQMDLTM-UHFFFAOYSA-N", "LHJGJYXLEPZJPM-UHFFFAOYSA-N",
+        "LINPIYWFGCPVIE-UHFFFAOYSA-N"
+    ])
+
+    for k, n in enumerate(spectrum):
+        assert n.get("inchikey").lower() == expected_inchikey[k].lower(), "Expected different InChIKey."