Repository: biopython/biopython

Issue:
KEGG.Compound.parse not returning mass 
### Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

1.78
3.9.12
Windows 10 Pro

### Expected behaviour

Calling KEGG.Compound.parse on a KEGG record should return a KEGG record object containing the mass. For example, compound C00120 should have a mass attribute containing 244.0882.

### Actual behaviour

However, no mass attribute is returned. 

### Steps to reproduce

```
from Bio.KEGG.Compound import parse
from Bio.KEGG.REST import kegg_get
c00120 = next(parse(kegg_get('C00120')))
print(c00120.mass)
```
### Fix
This is because the KEGG record now uses separate EXACT_MASS and MOL_WEIGHT fields (can be seen by running kegg_get('C00120').read()). Fixed by replacing line 156 in KEGG.Compound.__init__.py with:
`elif keyword == "EXACT_MASS  ":`




Discussion:

Resolving patch:
diff --git a/Bio/KEGG/Compound/__init__.py b/Bio/KEGG/Compound/__init__.py
--- a/Bio/KEGG/Compound/__init__.py
+++ b/Bio/KEGG/Compound/__init__.py
@@ -153,7 +153,7 @@ def parse(handle):
             record.pathway.append(pathway)
         elif keyword == "FORMULA     ":
             record.formula = data
-        elif keyword == "MASS        ":
+        elif keyword in ("MASS        ", "EXACT_MASS  "):
             record.mass = data
         elif keyword == "DBLINKS     ":
             if ":" in data:


Test patch:
diff --git a/Tests/test_KEGG.py b/Tests/test_KEGG.py
--- a/Tests/test_KEGG.py
+++ b/Tests/test_KEGG.py
@@ -134,7 +134,7 @@ def test_sample(self):
             records = list(Compound.parse(handle))
         self.assertEqual(len(records), 8)
         self.assertEqual(records[1].entry, "C00017")
-        self.assertEqual(records[1].mass, "")  # Why?
+        self.assertEqual(records[1].mass, "")
         self.assertEqual(records[1].formula, "C2H4NO2R(C2H2NOR)n")
         self.assertEqual(records[1].name, ["Protein"])
         self.assertEqual(
@@ -145,12 +145,13 @@ def test_sample(self):
         self.assertEqual(records[1].structures, [])
         self.assertEqual(records[1].dblinks[0], ("PubChem", ["3319"]))
         self.assertEqual(
-            str(records[-1]).replace(" ", "").split("\n")[:10],
+            str(records[-1]).replace(" ", "").split("\n")[:11],
             [
                 "ENTRYC01386",
                 "NAMENH2Mec",
                 "7-Amino-4-methylcoumarin",
                 "FORMULAC10H9NO2",
+                "MASS175.0633",
                 "DBLINKSCAS:26093-31-2",
                 "PubChem:4580",
                 "ChEBI:51771",
@@ -167,6 +168,17 @@ def test_irregular(self):
         self.assertEqual(len(records), 2)
         self.assertEqual(records[0].entry, "C01454")
 
+    def test_mass(self):
+        """record.mass tests."""
+        with open("KEGG/compound.sample") as handle:
+            records = list(Compound.parse(handle))
+        self.assertEqual(records[0].entry, "C00023")
+        self.assertEqual(records[0].mass, "55.9349")
+        self.assertEqual(records[2].entry, "C00099")
+        self.assertEqual(records[2].mass, "89.0477")
+        self.assertEqual(records[3].entry, "C00294")
+        self.assertEqual(records[3].mass, "268.0808")
+
 
 class MapTests(unittest.TestCase):
     """Bio.KEGG.Map tests."""