Repository: biopython/biopython

Issue:
GenBank structured_comment with missing information merged into previous entry
### Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

```python
>>> import sys; print(sys.version)
3.10.8 (main, Oct 11 2022, 11:35:05) [GCC 11.2.0]
>>> import platform; print(platform.python_implementation()); print(platform.platform())
CPython
Linux-5.15.0-88-generic-x86_64-with-glibc2.35
>>> import Bio; print(Bio.__version__)
1.81
```


### Expected behaviour

I am processing a genbank file using SeqIO and extracting information from the annotation. However, some attributes of the genbank file are empty and, in the resulting dictionary, they are merged with the line before.

For example, when trying to extract the information about complete and partial rRNAs using ```seq_record.annotations['structured_comment']['Genome-Annotation-Data']['complete rRNAs']``` and ```seq_record.annotations['structured_comment']['Genome-Annotation-Data']['partial rRNAs']``` from an annotation that looks like this:

```
rRNAs                             :: 2, 1, 1 (5S, 16S, 23S)
complete rRNAs                    :: 2, 1, 1 (5S, 16S, 23S)
partial rRNAs                     ::
tRNAs                             :: 34
```

I would expect to obtain:

```python
>>> print(seq_record.annotations['structured_comment']['Genome-Annotation-Data']['complete rRNAs'])
2, 1, 1 (5S, 16S, 23S)
```

### Actual behaviour

Instead, what I obtain is this: 

```python
>>> print(seq_record.annotations['structured_comment']['Genome-Annotation-Data']['complete rRNAs'])
2, 1, 1 (5S, 16S, 23S) partial rRNAs                     ::
``` 

So when a line contains no information, it gets merged to the values of the previous line. In this case, the key ```partial rRNAs``` does not exist.

### Steps to reproduce

```python
from Bio import SeqIO
input = "GCF_012367175.1_ASM1236717v1_genomic.gbff"
contig = SeqIO.index(input, "genbank")['NZ_JAAEVG010000101.1']
print(contig.annotations['structured_comment']['Genome-Annotation-Data']['complete rRNAs'])
```

[GCF_012367175.1_ASM1236717v1_genomic.gbff.zip](https://github.com/biopython/biopython/files/13365208/GCF_012367175.1_ASM1236717v1_genomic.gbff.zip)




Discussion:
@biologyguy as our GenBank structured_comment expert, would you be able to take at look at this please?
Sure, I can have a look this weekend. Been out of the loop for awhile though!

Resolving patch:
diff --git a/Bio/GenBank/Scanner.py b/Bio/GenBank/Scanner.py
--- a/Bio/GenBank/Scanner.py
+++ b/Bio/GenBank/Scanner.py
@@ -1775,10 +1775,10 @@ def _feed_header_lines(self, consumer, lines):
                                     comment_list.append(data)
                             elif (
                                 structured_comment_key is not None
-                                and self.STRUCTURED_COMMENT_DELIM in data
+                                and self.STRUCTURED_COMMENT_DELIM.strip() in data
                             ):
                                 match = re.search(
-                                    rf"(.+?)\s*{self.STRUCTURED_COMMENT_DELIM}\s*(.+)",
+                                    rf"(.+?)\s*{self.STRUCTURED_COMMENT_DELIM.strip()}\s*(.*)",
                                     data,
                                 )
                                 structured_comment_dict[structured_comment_key][


Test patch:
diff --git a/Tests/GenBank/EU851978.gbk b/Tests/GenBank/EU851978.gbk
--- a/Tests/GenBank/EU851978.gbk
+++ b/Tests/GenBank/EU851978.gbk
@@ -18,6 +18,7 @@ COMMENT     ##FluData-START##
             LabID             :: 2008704957
             Antigen_Character :: A/Solomon Islands/03/2006-like (H1N1)
             Passage_Details   :: SPFCK3E1
+            Empty_structured  ::
             Drug Sensitivity  :: adamantane-sensitive, oseltamivir-sensitive
             LANL Accession    :: ISDN306605
             ##FluData-END##
diff --git a/Tests/GenBank/EU851978_output.gbk b/Tests/GenBank/EU851978_output.gbk
--- a/Tests/GenBank/EU851978_output.gbk
+++ b/Tests/GenBank/EU851978_output.gbk
@@ -18,6 +18,7 @@ COMMENT     ##FluData-START##
             LabID             :: 2008704957
             Antigen_Character :: A/Solomon Islands/03/2006-like (H1N1)
             Passage_Details   :: SPFCK3E1
+            Empty_structured  ::
             Drug Sensitivity  :: adamantane-sensitive, oseltamivir-sensitive
             LANL Accession    :: ISDN306605
             ##FluData-END##
diff --git a/Tests/test_GenBank.py b/Tests/test_GenBank.py
--- a/Tests/test_GenBank.py
+++ b/Tests/test_GenBank.py
@@ -7704,7 +7704,7 @@ def test_structured_comment_parsing(self):
         self.assertEqual(
             record.annotations["structured_comment"]["FluData"]["LabID"], "2008704957"
         )
-        self.assertEqual(len(record.annotations["structured_comment"]["FluData"]), 5)
+        self.assertEqual(len(record.annotations["structured_comment"]["FluData"]), 6)
         path = "GenBank/EU851978_output.gbk"
         with open(path) as ifile:
             self.assertEqual(record.format("gb"), ifile.read())
diff --git a/Tests/test_SeqIO_Insdc.py b/Tests/test_SeqIO_Insdc.py
--- a/Tests/test_SeqIO_Insdc.py
+++ b/Tests/test_SeqIO_Insdc.py
@@ -8,6 +8,7 @@
 
 from io import StringIO
 
+from Bio import BiopythonParserWarning
 from Bio import SeqIO
 from Bio.Seq import Seq
 from Bio.SeqFeature import SimpleLocation
@@ -52,7 +53,8 @@ def test_annotation3(self):
 
     def test_annotation4(self):
         """Check parsing of annotation from EMBL files (4)."""
-        record = SeqIO.read("EMBL/location_wrap.embl", "embl")
+        with self.assertWarns(BiopythonParserWarning):
+            record = SeqIO.read("EMBL/location_wrap.embl", "embl")
         self.assertEqual(len(record), 120)
         self.assertNotIn("keywords", record.annotations)
         # The ID line has the topology as unspecified: