diff --git a/egcg_core/ncbi.py b/egcg_core/ncbi.py
index 13f74d6..69cc44c 100644
--- a/egcg_core/ncbi.py
+++ b/egcg_core/ncbi.py
@@ -76,7 +76,7 @@ def _fetch_from_eutils(species):
         rank = None
         if match:
             rank = match.group(1)
-        if rank == 'species':
+        if rank in ['species', 'subspecies']:
             scientific_name = common_name = None
             match = re.search('<ScientificName>(.+?)</ScientificName>', r.text, re.MULTILINE)
             if match:

Canis lupus familiaris NCBI query returns None
Because _C. l. familiaris_ has `subspecies` in its efetch, the regex system in `fetch_from_eutils` breaks down. We should query the XML more robustly.
diff --git a/tests/test_ncbi.py b/tests/test_ncbi.py
index ef931bb..af10556 100644
--- a/tests/test_ncbi.py
+++ b/tests/test_ncbi.py
@@ -24,6 +24,11 @@ def test_fetch_from_eutils():
         <OtherNames><CommonName>a common name</CommonName></OtherNames>
         <Rank>species</Rank>
     '''
+    ncbi_fetch_data_sub_spe = '''
+        <ScientificName>Genus species</ScientificName>
+        <OtherNames><CommonName>a common name</CommonName></OtherNames>
+        <Rank>subspecies</Rank>
+    '''
 
     patched_get = patch(
         'egcg_core.ncbi.requests.get',
@@ -34,7 +39,15 @@ def test_fetch_from_eutils():
             FakeRestResponse(content=ncbi_fetch_data)
         )
     )
-
+    patched_get2 = patch(
+        'egcg_core.ncbi.requests.get',
+        side_effect=(
+            FakeRestResponse(content=ncbi_search_data),
+            FakeRestResponse(content=ncbi_fetch_data_sub_spe),
+            FakeRestResponse(content=ncbi_fetch_data_sub_spe),
+            FakeRestResponse(content=ncbi_fetch_data_sub_spe)
+        )
+    )
     with patched_get as mocked_get:
         obs = fetch_from_eutils('a_species')
         assert obs == ('1337', 'Genus species', 'a common name')
@@ -46,6 +59,10 @@ def test_fetch_from_eutils():
             'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi',
             params={'db': 'Taxonomy', 'id': '1337'}
         )
+    with patched_get2:
+        obs = fetch_from_eutils('a_species')
+        assert obs == ('1337', 'Genus species', 'a common name')
+
 
 
 def test_cache():

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi==2025.1.31
charset-normalizer==3.4.1
-e git+https://github.com/EdinburghGenomics/EGCG-Core.git@a835cffab69da2193d4653f31230f0d487596b78#egg=EGCG_Core
exceptiongroup==1.2.2
genologics==1.0.0
idna==3.10
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
PyYAML==6.0.2
requests==2.32.3
tomli==2.2.1
urllib3==2.3.0

name: EGCG-Core
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - exceptiongroup==1.2.2
      - genologics==1.0.0
      - idna==3.10
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - pyyaml==6.0.2
      - requests==2.32.3
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/EGCG-Core

tests/test_ncbi.py::test_fetch_from_eutils
tests/test_ncbi.py::test_cache tests/test_ncbi.py::test_get_species_name
egcg_core/ncbi.py
egcg_core/ncbi.py