Exemplo n.º 1
0
def test_has_members_er():
    bpe = bp.model.getByID(uri_prefix +\
                     'ProteinReference_971cec47bcd850e2b7d602f0416edacf')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    assert (bpc._has_members(bpe))

    bpe = bp.model.getByID('http://identifiers.org/uniprot/P56159')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    assert (not bpc._has_members(bpe))
Exemplo n.º 2
0
def test_has_members_er():
    bpe = bp.model.getByID(uri_prefix +\
                     'ProteinReference_971cec47bcd850e2b7d602f0416edacf')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    assert(bpc._has_members(bpe))

    bpe = bp.model.getByID('http://identifiers.org/uniprot/P56159')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    assert(not bpc._has_members(bpe))
Exemplo n.º 3
0
def bipax_model_to_sbgn(jModel):
    do_layout = False # For some reason being problematic if we set this to True
    jConverter = JL3ToSBGNPDConverter(None, None, do_layout)
    jBaos = JByteArrayOutputStream()
    output_stream = cast('java.io.OutputStream', jBaos)

    # jConverter.writeSBGN method does not create the bbox objects for
    # the glyphs, not sure but maybe it would be creating them if we were able
    # to run it with layout enabled. Therefore, we need to jConverter.createSBGN method
    # and do the rest of the work below.
    jSbgn = jConverter.createSBGN(jModel)
    jMap = jSbgn.getMap()
    jGlyphs = jMap.getGlyph()
    jGlyphs = list(jGlyphs.toArray())

    assign_bbox_to_glyphs(jGlyphs)

    context = JAXBContext.newInstance('org.sbgn.bindings')
    marshaller = context.createMarshaller()
    marshaller.setProperty(JMarshaller.JAXB_FORMATTED_OUTPUT, JBoolean(True))
    marshaller.marshal(jSbgn, output_stream)

    res = jBaos.toString(JStandardCharsets.UTF_8.name())

    return res
Exemplo n.º 4
0
def test_get_mod_feature():
    bpe = bp.model.getByID(uri_prefix +\
            'ModificationFeature_bd27a53570fb9a5094bb5929bd973217')
    mf = cast(bpc._bp('ModificationFeature'), bpe)
    mc = bpc.BiopaxProcessor._extract_mod_from_feature(mf)
    assert (mc[0] == 'phosphorylation')
    assert (mc[1] == 'T')
    assert (mc[2] == '274')
Exemplo n.º 5
0
def test_get_mod_feature():
    bpe = bp.model.getByID(uri_prefix +\
            'ModificationFeature_bd27a53570fb9a5094bb5929bd973217')
    mf = cast(bpc._bp('ModificationFeature'), bpe)
    mc = bpc.BiopaxProcessor._extract_mod_from_feature(mf)
    assert(mc.mod_type == 'phosphorylation')
    assert(mc.residue == 'T')
    assert(mc.position == '274')
Exemplo n.º 6
0
def test_get_entity_mods():
    bpe = bp.model.getByID(uri_prefix +\
            'Protein_7aeb1631f64e49491b7a0303aaaec536')
    protein = cast(bpc._bp('Protein'), bpe)
    mods = bpc.BiopaxProcessor._get_entity_mods(protein)
    assert(len(mods) == 5)
    mod_types = set([m.mod_type for m in mods])
    assert(mod_types == set(['phosphorylation']))
    residues = set([m.residue for m in mods])
    assert(residues == set(['Y']))
    mod_pos = set([m.position for m in mods])
    assert(mod_pos == set(['1035', '1056', '1128', '1188', '1242']))
Exemplo n.º 7
0
def test_get_entity_mods():
    bpe = bp.model.getByID(uri_prefix +\
            'Protein_7aeb1631f64e49491b7a0303aaaec536')
    protein = cast(bpc._bp('Protein'), bpe)
    mods = bpc.BiopaxProcessor._get_entity_mods(protein)
    assert (len(mods) == 5)
    mod_types = set([m[0] for m in mods])
    assert (mod_types == set(['phosphorylation']))
    residues = set([m[1] for m in mods])
    assert (residues == set(['Y']))
    mod_pos = set([m[2] for m in mods])
    assert (mod_pos == set(['1035', '1056', '1128', '1188', '1242']))
Exemplo n.º 8
0
    def _extract_mod_from_feature(mf):
        """Extract the type of modification and the position from
        a ModificationFeature object in the INDRA format."""
        # ModificationFeature / SequenceModificationVocabulary
        mf_type = mf.getModificationType()
        if mf_type is None:
            return None
        mf_type_terms = mf_type.getTerm().toArray()
        known_mf_type = None
        for t in mf_type_terms:
            mf_type_indra = BiopaxProcessor._mftype_dict.get(t)
            if mf_type_indra is None:
                logger.info('Unknown modification type term: %s' % t)
            else:
                known_mf_type = mf_type_indra
        if not known_mf_type:
            logger.info('Ignored modification type %s' % mf_type_terms[0])
            return None
        else:
            mod_type, residue = known_mf_type

        # getFeatureLocation returns SequenceLocation, which is the
        # generic parent class of SequenceSite and SequenceInterval.
        # Here we need to cast to SequenceSite in order to get to
        # the sequence position.
        mf_pos = mf.getFeatureLocation()
        if mf_pos is not None:
            # If it is not a SequenceSite we can't handle it
            if not mf_pos.modelInterface.getName() == \
                'org.biopax.paxtools.model.level3.SequenceSite':
                return None
            mf_site = cast(_bp('SequenceSite'), mf_pos)
            mf_pos_status = mf_site.getPositionStatus()
            if mf_pos_status is None:
                mod_pos = None
            elif mf_pos_status and mf_pos_status.toString() != 'EQUAL':
                logger.info('Modification site position is %s' %
                            mf_pos_status.toString())
            else:
                mod_pos = mf_site.getSequencePosition()
                mod_pos = '%s' % mod_pos
        else:
            mod_pos = None
        mc = (mod_type, residue, mod_pos)
        return mc
Exemplo n.º 9
0
    def _extract_mod_from_feature(mf):
        """Extract the type of modification and the position from
        a ModificationFeature object in the INDRA format."""
        # ModificationFeature / SequenceModificationVocabulary
        mf_type = mf.getModificationType()
        if mf_type is None:
            return None
        mf_type_terms = mf_type.getTerm().toArray()
        known_mf_type = None
        for t in mf_type_terms:
            mf_type_indra = BiopaxProcessor._mftype_dict.get(t)
            if mf_type_indra is None:
                logger.info('Unknown modification type term: %s' % t)
            else:
                known_mf_type = mf_type_indra
        if not known_mf_type:
            logger.info('Ignored modification type %s' % mf_type_terms[0])
            return None
        else:
            mod_type, residue = known_mf_type

        # getFeatureLocation returns SequenceLocation, which is the
        # generic parent class of SequenceSite and SequenceInterval.
        # Here we need to cast to SequenceSite in order to get to
        # the sequence position.
        mf_pos = mf.getFeatureLocation()
        if mf_pos is not None:
            # If it is not a SequenceSite we can't handle it
            if not mf_pos.modelInterface.getName() == \
                'org.biopax.paxtools.model.level3.SequenceSite':
                return None
            mf_site = cast(_bp('SequenceSite'), mf_pos)
            mf_pos_status = mf_site.getPositionStatus()
            if mf_pos_status is None:
                mod_pos = None
            elif mf_pos_status and mf_pos_status.toString() != 'EQUAL':
                logger.info('Modification site position is %s' %
                            mf_pos_status.toString())
            else:
                mod_pos = mf_site.getSequencePosition()
        else:
            mod_pos = None
        mc = ModCondition(mod_type, residue, mod_pos)
        return mc
Exemplo n.º 10
0
    def _get_modification_site(self, modPE):
        # Do we need to look at EntityFeatures?
        modMF = [
            mf for mf in modPE.getFeature().toArray()
            if isinstance(mf, bpimpl('ModificationFeature'))
        ]
        mod_pos = []
        mod = []

        for mf in modMF:
            # ModificationFeature / SequenceModificationVocabulary
            mf_type = mf.getModificationType().getTerm().toArray()[0]
            if len(mf.getModificationType().getTerm().toArray()) != 1:
                warnings.warn('Other than one modification term')
            try:
                mod_type = self._mftype_dict[mf_type]
            except KeyError:
                warnings.warn('Unknown modification type %s' % mf_type)
                continue

            mod.append(mod_type)

            # getFeatureLocation returns SequenceLocation, which is the
            # generic parent class of SequenceSite and SequenceInterval.
            # Here we need to cast to SequenceSite in order to get to
            # the sequence position.
            mf_pos = mf.getFeatureLocation()
            if mf_pos is not None:
                mf_site = cast(bp('SequenceSite'), mf_pos)
                mf_pos_status = mf_site.getPositionStatus()
                if mf_pos_status and mf_pos_status.toString() != 'EQUAL':
                    warnings.warn('Modification site position is %s' %
                                  mf_pos_status.toString())
                mod_pos.append(mf_site.getSequencePosition())
            else:
                mod_pos.append(None)
            # Do we need to look at mf.getFeatureLocationType()?
            # It seems to be always None.
            # mf_pos_type = mf.getFeatureLocationType()
        return mod, mod_pos
Exemplo n.º 11
0
    def _get_modification_site(self, modPE):
        # Do we need to look at EntityFeatures?
        modMF = [mf for mf in modPE.getFeature().toArray()
                 if isinstance(mf, bpimpl('ModificationFeature'))]
        mod_pos = []
        mod = []

        for mf in modMF:
            # ModificationFeature / SequenceModificationVocabulary
            mf_type = mf.getModificationType().getTerm().toArray()[0]
            if len(mf.getModificationType().getTerm().toArray()) != 1:
                warnings.warn('Other than one modification term')
            try:
                mod_type = self._mftype_dict[mf_type]
            except KeyError:
                warnings.warn('Unknown modification type %s' % mf_type)
                continue

            mod.append(mod_type)

            # getFeatureLocation returns SequenceLocation, which is the
            # generic parent class of SequenceSite and SequenceInterval.
            # Here we need to cast to SequenceSite in order to get to
            # the sequence position.
            mf_pos = mf.getFeatureLocation()
            if mf_pos is not None:
                mf_site = cast(bp('SequenceSite'), mf_pos)
                mf_pos_status = mf_site.getPositionStatus()
                if mf_pos_status and mf_pos_status.toString() != 'EQUAL':
                    warnings.warn('Modification site position is %s' %
                                  mf_pos_status.toString())
                mod_pos.append(mf_site.getSequencePosition())
            else:
                mod_pos.append(None)
            # Do we need to look at mf.getFeatureLocationType()?
            # It seems to be always None.
            # mf_pos_type = mf.getFeatureLocationType()
        return mod, mod_pos
Exemplo n.º 12
0
def test_is_complex():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_24213.2')
    bpe = cast(bpc._bp('Complex'), bpe)
    assert (bpc._is_complex(bpe))
Exemplo n.º 13
0
def test_is_mod2():
    bpe = bp.model.getByID(uri_prefix +\
                    'FragmentFeature_806ae27c773eb2d9138269552899c242')
    bpe = cast(bpc._bp('FragmentFeature'), bpe)
    assert (not bpc._is_modification(bpe))
Exemplo n.º 14
0
def cast_biopax_element(bpe):
    """ Casts a generic BioPAXElement object into a specific type.
    This is useful when a search only returns generic elements. """
    return cast(bpe.getModelInterface().getName(), bpe)
Exemplo n.º 15
0
def test_uniprot_id_er():
    bpe = bp.model.getByID('http://identifiers.org/uniprot/Q15303')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    ids = bp._get_uniprot_id(bpe)
    assert('Q15303' == ids)
Exemplo n.º 16
0
def test_has_members_pe2():
    bpe = bp.model.getByID(uri_prefix +
                           'Protein_7d526475fd43d0a07ca1a596fe81aae0')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert (not bpc._has_members(bpe))
Exemplo n.º 17
0
def test_uniprot_id_er():
    bpe = bp.model.getByID('http://identifiers.org/uniprot/Q15303')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    ids = bp._get_uniprot_id(bpe)
    assert ('Q15303' == ids)
Exemplo n.º 18
0
def test_has_members_pe2():
    bpe = bp.model.getByID(uri_prefix + 'Protein_7d526475fd43d0a07ca1a596fe81aae0')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert(not bpc._has_members(bpe))
Exemplo n.º 19
0
def cast_biopax_element(bpe):
    """ Casts a generic BioPAXElement object into a specific type.
    This is useful when a search only returns generic elements. """
    return cast(bpe.getModelInterface().getName(), bpe)
Exemplo n.º 20
0
def test_has_members_pe():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117345.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert(bpc._has_members(bpe))
Exemplo n.º 21
0
def test_uniprot_id_pe():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117886.3')
    bpe = cast(bpc._bp('Protein'), bpe)
    ids = bp._get_uniprot_id(bpe)
    assert('Q15303' == ids)
Exemplo n.º 22
0
def test_name_uniprot_id_no_hgnc_pe():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_27053.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    name = bp._get_element_name(bpe)
    assert(name == 'IGHV3-13')
Exemplo n.º 23
0
def test_uniprot_id_pe():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117886.3')
    bpe = cast(bpc._bp('Protein'), bpe)
    ids = bp._get_uniprot_id(bpe)
    assert ('Q15303' == ids)
Exemplo n.º 24
0
def test_is_er2():
    bpe = bp.model.getByID(uri_prefix +\
                     'ProteinReference_971cec47bcd850e2b7d602f0416edacf')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    assert (bpc._is_reference(bpe))
Exemplo n.º 25
0
def test_name_uniprot_id_no_hgnc_pe():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_27053.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    name = bp._get_element_name(bpe)
    assert (name == 'IGHV3-13')
Exemplo n.º 26
0
def test_is_complex2():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117345.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert not bpc._is_complex(bpe)
Exemplo n.º 27
0
def test_get_hgnc_id():
    bpe = bp.model.getByID('http://identifiers.org/uniprot/Q15303')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    hgnc_id = bp._get_hgnc_id(bpe)
    assert (hgnc_id == '3432')
Exemplo n.º 28
0
def test_is_complex():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_24213.2')
    bpe = cast(bpc._bp('Complex'), bpe)
    assert(bpc._is_complex(bpe))
Exemplo n.º 29
0
def test_is_er():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117345.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert(not bpc._is_reference(bpe))
Exemplo n.º 30
0
def test_get_hgnc_id():
    bpe = bp.model.getByID('http://identifiers.org/uniprot/Q15303')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    hgnc_id = bp._get_hgnc_id(bpe)
    assert(hgnc_id == '3432')
Exemplo n.º 31
0
def test_has_members_pe():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117345.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert (bpc._has_members(bpe))
Exemplo n.º 32
0
def test_is_er2():
    bpe = bp.model.getByID(uri_prefix +\
                     'ProteinReference_971cec47bcd850e2b7d602f0416edacf')
    bpe = cast(bpc._bp('ProteinReference'), bpe)
    assert(bpc._is_reference(bpe))
Exemplo n.º 33
0
def test_is_er():
    bpe = bp.model.getByID('http://identifiers.org/reactome/REACT_117345.2')
    bpe = cast(bpc._bp('Protein'), bpe)
    assert (not bpc._is_reference(bpe))
Exemplo n.º 34
0
def test_is_mod():
    bpe = bp.model.getByID(uri_prefix +\
                    'ModificationFeature_59c99eae672d2a11e971a93c7848d5c6')
    bpe = cast(bpc._bp('ModificationFeature'), bpe)
    assert(bpc._is_modification(bpe))
Exemplo n.º 35
0
def test_is_mod():
    bpe = bp.model.getByID(uri_prefix +\
                    'ModificationFeature_59c99eae672d2a11e971a93c7848d5c6')
    bpe = cast(bpc._bp('ModificationFeature'), bpe)
    assert (bpc._is_modification(bpe))
Exemplo n.º 36
0
def test_is_mod2():
    bpe = bp.model.getByID(uri_prefix +\
                    'FragmentFeature_806ae27c773eb2d9138269552899c242')
    bpe = cast(bpc._bp('FragmentFeature'), bpe)
    assert(not bpc._is_modification(bpe))