def _parse_record(self, lines: List[str]) -> Optional[UniProtRecord]:
        """Parse a single UniProt record from lines."""
        if not lines:
            return None

        record = UniProtRecord(
            id="",
            accession=[],
            description="",
            gene_names=[],
            organism="",
            comments=[],
            keywords=[],
            features=[],
            sequence_length=0,
            sequence_mw=0,
            dates=[],
            taxonomy=[],
            taxonomy_id={},
            cross_references=[],
            citations=[],
        )

        current_field = None

        for line in lines:
            if not line.strip():
                continue

            if line.startswith("//"):
                break

            field = line[:2]

            if field not in self.include_field_codes and current_field != "citations":
                continue

            value = line[5:].strip().rstrip(";")

            if field != "RA":
                # Remove trailing period
                # Do not remove trailing period from authors names
                value = value.rstrip(".")

            if field == "ID":
                record.id = value.split()[0]
                current_field = "id"
            elif field == "AC":
                record.accession = [acc.strip() for acc in value.split(";")]
                current_field = "accession"
            elif field == "DE":
                record.description = value
                current_field = "description"
            elif field == "GN":
                record.gene_names = [name.strip() for name in value.split(";")]
                current_field = "gene_names"
            elif field == "OS":
                record.organism = value
                current_field = "organism"
            elif field == "CC":
                if value.startswith("-!-"):
                    record.comments.append(value[4:])
                elif value.startswith("---"):
                    # Skip separator lines
                    continue
                elif any(word in value.lower() for word in ["copyright", "license"]):
                    # Skip standard UniProt footer comments
                    continue
                else:
                    record.comments.append(value)
                current_field = "comments"
            elif field == "KW":
                # Handle multiple KW lines by extending the list
                record.keywords.extend([kw.strip() for kw in value.split(";")])
                current_field = "keywords"
            elif field == "FT":
                if value:
                    feature_parts = value.split()
                    if len(feature_parts) >= 2:
                        record.features.append(
                            {
                                "type": feature_parts[0],
                                "location": feature_parts[1],
                                "description": " ".join(feature_parts[2:])
                                if len(feature_parts) > 2
                                else "",
                            }
                        )
                current_field = "features"
            elif field == "SQ":
                if "SEQUENCE" in value:
                    parts = value.split(";")
                    record.sequence_length = int(parts[0].split()[1])
                    record.sequence_mw = int(parts[1].split()[0])
                current_field = "sequence"
            elif field == "OC":
                record.taxonomy.extend(value.split("; "))
            elif field == "OX":
                # Parse taxonomy database qualifier and code
                # Format: OX   Taxonomy_database_Qualifier=Taxonomic code;
                parts = value.split("=")
                if len(parts) == 2:
                    record.taxonomy_id = {"database": parts[0], "code": parts[1]}
            elif field == "RN":
                # Start a new citation block
                current_citation = {
                    "number": value.strip("[]"),
                    "position": [],
                    "comment": [],
                    "cross_references": [],
                    "authors": "",
                    "title": "",
                    "location": [],
                }

                record.citations.append(current_citation)
                current_field = "citations"
            elif field == "RP" and current_field == "citations":
                current_citation["position"].append(value)
            elif field == "RC" and current_field == "citations":
                current_citation["comment"].append(value)
            elif field == "RX" and current_field == "citations":
                current_citation["cross_references"].append(value)
            elif field == "RA" and current_field == "citations":
                # Concatenate author lines with space
                current_citation["authors"] = (
                    current_citation["authors"] + " " + value
                ).strip()
            elif field == "RT" and current_field == "citations":
                # Concatenate title lines with space and remove quotes
                title = (current_citation["title"] + " " + value).strip()
                current_citation["title"] = title.strip('"')
            elif field == "RL" and current_field == "citations":
                current_citation["location"].append(value)
            elif field == "DR":
                # Parse database cross-references
                # Format: DR   RESOURCE_ABBREVIATION; RESOURCE_IDENTIFIER; OPTIONAL_INFORMATION_1[; OPTIONAL_INFORMATION_2][; OPTIONAL_INFORMATION_3].
                parts = value.split("; ")
                if len(parts) >= 2:
                    record.cross_references.append(
                        {
                            "abbrev": parts[0],
                            "id": parts[1],
                            "info": parts[2:],
                        }
                    )
                current_field = "cross_references"

        return record
Parse a single UniProt record from lines.
llama-index-integrations/readers/llama-index-readers-uniprot/llama_index/readers/uniprot/base.py