Repository: matchms/matchms

Issue:
load_from_usi API call is deprecated
**Describe the bug**
`load_from_usi` always returns None. 

**To Reproduce**
Try to load any USI. Tested on the USI from the README and the documentation:

```python
from matchms.importing import load_from_usi

load_from_usi("mzspec:GNPS:GNPS-LIBRARY:accession:CCMSLIB00000424840")
load_from_usi("mzspec:MSV000086109:BD5_dil2x_BD5_01_57213:scan:760")
```

**Expected behavior**
Return a valid spectrum


Discussion:

Patch:
diff --git a/matchms/filtering/peak_processing/normalize_intensities.py b/matchms/filtering/peak_processing/normalize_intensities.py
index b80ac38e..1cf3a4d1 100644
--- a/matchms/filtering/peak_processing/normalize_intensities.py
+++ b/matchms/filtering/peak_processing/normalize_intensities.py
@@ -21,9 +21,8 @@ def normalize_intensities(spectrum_in: SpectrumType) -> SpectrumType:
     max_intensity = np.max(spectrum.peaks.intensities)
 
     if max_intensity <= 0:
-        logger.warning("Peaks of spectrum with all peak intensities <= 0 were deleted.")
-        spectrum.peaks = Fragments(mz=np.array([]), intensities=np.array([]))
-        return spectrum
+        logger.warning("Spectrum with all peak intensities <= 0 was set to None.")
+        return None
 
     # Normalize peak intensities
     mz, intensities = spectrum.peaks.mz, spectrum.peaks.intensities
diff --git a/matchms/importing/load_from_usi.py b/matchms/importing/load_from_usi.py
index 208d3e85..c7079c60 100644
--- a/matchms/importing/load_from_usi.py
+++ b/matchms/importing/load_from_usi.py
@@ -8,7 +8,7 @@ from ..Spectrum import Spectrum
 logger = logging.getLogger("matchms")
 
 
-def load_from_usi(usi: str, server: str = "https://metabolomics-usi.ucsd.edu",
+def load_from_usi(usi: str, server: str = "https://metabolomics-usi.gnps2.org",
                   metadata_harmonization: bool = True):
     """Load spectrum from metabolomics USI.
 
@@ -39,6 +39,10 @@ def load_from_usi(usi: str, server: str = "https://metabolomics-usi.ucsd.edu",
 
     if response.status_code == 404:
         return None
+
+    if "application/json" not in response.headers.get("Content-Type"):
+        return None
+
     # Extract data and create Spectrum object
     try:
         spectral_data = response.json()


Test patch:
diff --git a/tests/filtering/test_normalize_intensities.py b/tests/filtering/test_normalize_intensities.py
index 4b149525..e5713d62 100644
--- a/tests/filtering/test_normalize_intensities.py
+++ b/tests/filtering/test_normalize_intensities.py
@@ -52,9 +52,8 @@ def test_normalize_intensities_all_zeros(caplog):
 
     spectrum = normalize_intensities(spectrum_in)
 
-    assert len(spectrum.peaks.intensities) == 0, "Expected no peak intensities."
-    assert len(spectrum.peaks.mz) == 0, "Expected no m/z values. "
-    msg = "Peaks of spectrum with all peak intensities <= 0 were deleted."
+    assert spectrum is None, "Expected spectrum to be set to None."
+    msg = "Spectrum with all peak intensities <= 0 was set to None."
     assert msg in caplog.text, "Expected log message."
 
 
diff --git a/tests/importing/test_load_from_usi.py b/tests/importing/test_load_from_usi.py
index c2e6e270..cc25da2a 100644
--- a/tests/importing/test_load_from_usi.py
+++ b/tests/importing/test_load_from_usi.py
@@ -8,8 +8,10 @@ from ..builder_Spectrum import SpectrumBuilder
 def test_normal(mock_get):
     mock_get.return_value = Mock(ok=True)
     mock_get.return_value.json.return_value = {"peaks": [[1., 2.], [3., 4.]]}
+    mock_get.return_value.headers.get = Mock(return_value="application/json")
+
     spec = load_from_usi("something")
-    expected_metadata = {"usi": "something", "server": "https://metabolomics-usi.ucsd.edu", "precursor_mz": None}
+    expected_metadata = {"usi": "something", "server": "https://metabolomics-usi.gnps2.org", "precursor_mz": None}
     expected = SpectrumBuilder().with_mz(np.array([1., 3.])).with_intensities(
         np.array([2., 4.])).with_metadata(expected_metadata,
                                           metadata_harmonization=True).build()
@@ -21,6 +23,8 @@ def test_404(mock_get):
     mock_get.return_value = Mock(ok=True)
     mock_get.return_value.status_code = 404
     mock_get.return_value.json.return_value = None
+    mock_get.return_value.headers.get = Mock(return_value="application/json")
+
     spec = load_from_usi("something")
     expected = None
     assert spec == expected
@@ -30,6 +34,20 @@ def test_404(mock_get):
 def test_no_peaks(mock_get):
     mock_get.return_value = Mock(ok=True)
     mock_get.return_value.json.return_value = {"peaks": []}
+    mock_get.return_value.headers.get = Mock(return_value="application/json")
+
     spec = load_from_usi("something")
     expected = None
     assert spec == expected
+
+
+def test_api_call():
+    usi = "mzspec:MASSBANK::accession:SM858102" # taken from load_from_usi docstring
+
+    spec = load_from_usi(usi)
+    
+    assert spec is not None
+    assert hasattr(spec, "peaks")
+    assert len(spec.peaks.mz) > 0
+    assert "usi" in spec.metadata
+    assert spec.metadata["usi"] == usi