Пример #1
0
def annotation_xml(item: libsbml.SBase) -> str:
    """Create Annotation string for the item.

    :param item: SBML object for which MathML content is to be generated
    :return: Annotation string for the item
    """
    if item.isSetAnnotation():
        return f"<pre>{item.getAnnotationString().decode('utf-8')}</pre>"
    return ""
Пример #2
0
def cvterm(item: libsbml.SBase) -> str:
    """Create HTML code fragment enclosing cvterm data for the item.

    :param item: SBML object for which cvterm data has to be displayed
    :return: HTML code fragment enclosing cvterm data for the item
    """
    if item.isSetAnnotation():
        return f'<div class="cvterm">{annotation_to_html(item)}</div>'
    return ""
Пример #3
0
    def cvterms(cls, sbase: libsbml.SBase) -> Optional[List]:
        """Parse CVTerms information.

        :param sbase: SBase instance
        """
        if not sbase.isSetAnnotation():
            return None

        cvterms = []
        for kcv in range(sbase.getNumCVTerms()):
            cv: libsbml.CVTerm = sbase.getCVTerm(kcv)
            # qualifier
            q_type = cv.getQualifierType()
            if q_type == libsbml.MODEL_QUALIFIER:
                qualifier = ModelQualifierType[cv.getModelQualifierType()]
            elif q_type == libsbml.BIOLOGICAL_QUALIFIER:
                qualifier = BiologicalQualifierType[
                    cv.getBiologicalQualifierType()]
            else:
                raise ValueError(f"Unsupported qualifier type: '{q_type}'")

            resources = [
                cv.getResourceURI(k) for k in range(cv.getNumResources())
            ]
            cvterms.append({
                "qualifier": qualifier,
                "resources": resources,
            })

        # add SBO term as CVTerm
        if sbase.isSetSBOTerm():
            sbo = sbase.getSBOTermID()
            sbo_in_cvs: bool = False
            for cv in cvterms:
                for resource in cv["resources"]:
                    if sbo in resource:
                        sbo_in_cvs = True
                        break
            if not sbo_in_cvs:
                cvterms = [{
                    "qualifier": "BQB_IS",
                    "resources": [f"https://identifiers.org/{sbo}"],
                }] + cvterms

        return cvterms
Пример #4
0
def annotation_html(item: libsbml.SBase) -> str:
    """Create annotation HTML content for the item.

    :param item: SBML object for which annotation HTML content is to be generated
    :return: HTML code fragment enclosing annotation for item
    """

    info = '<div class="cvterm">'
    if item.getSBOTerm() != -1:
        info += f"""
            <a href="{item.getSBOTermAsURL()}" target="_blank">
                {item.getSBOTermID()}
            </a><br />
            """
    if item.isSetAnnotation():
        info += annotation_to_html(item)
    info += "</div>"
    return info