def model_to_owl(model, fname):
    """Save a BioPAX model object as an OWL file.

    Parameters
    ----------
    model : org.biopax.paxtools.model.Model
        A BioPAX model object (java object).
    fname : str
        The name of the OWL file to save the model in.
    """
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        fileOS = autoclass('java.io.FileOutputStream')(fname)
    except JavaException:
        logger.error('Could not open data file %s' % fname)
        return
    l3_factory = autoclass(
        'org.biopax.paxtools.model.BioPAXLevel').L3.getDefaultFactory()
    model_out = l3_factory.createModel()
    for r in model.getObjects().toArray():
        model_out.add(r)
    io.convertToOWL(model_out, fileOS)

    fileOS.close()
def owl_to_model(fname):
    """Return a BioPAX model object from an OWL file.

    Parameters
    ----------
    fname : str
        The name of the OWL file containing the model.

    Returns
    -------
    biopax_model : org.biopax.paxtools.model.Model
        A BioPAX model object (java object).
    """
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        file_is = autoclass('java.io.FileInputStream')(fname)
    except JavaException:
        logger.error('Could not open data file %s' % fname)
        return
    try:
        biopax_model = io.convertFromOWL(file_is)
    except JavaException as e:
        logger.error('Could not convert data file %s to BioPax model' % fname)
        logger.error(e)
        return

    file_is.close()

    return biopax_model
def model_to_owl(model, fname):
    """Save a BioPAX model object as an OWL file.

    Parameters
    ----------
    model : org.biopax.paxtools.model.Model
        A BioPAX model object (java object).
    fname : str
        The name of the OWL file to save the model in.
    """
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        fileOS = autoclass('java.io.FileOutputStream')(fname)
    except JavaException:
        logger.error('Could not open data file %s' % fname)
        return
    l3_factory = autoclass('org.biopax.paxtools.model.BioPAXLevel').L3.getDefaultFactory()
    model_out = l3_factory.createModel()
    for r in model.getObjects().toArray():
        model_out.add(r)
    io.convertToOWL(model_out, fileOS)

    fileOS.close()
示例#4
0
    def process_text(self, text, format='json'):
        """Return a mentions JSON object given text.

        Parameters
        ----------
        text : str
            Text to be processed.
        format : str
            The format of the output to produce, one of "json" or "json_ld".
            Default: "json"

        Returns
        -------
        json_dict : dict
            A JSON object of mentions extracted from text.
        """
        if self.eidos_reader is None:
            eidos = autoclass(eidos_package + '.EidosSystem')
            self.eidos_reader = eidos(autoclass('java.lang.Object')())

        annot_doc = self.eidos_reader.extractFromText(text, False, False)
        if format == 'json':
            mentions = annot_doc.odinMentions()
            ser = autoclass(eidos_package +
                            '.serialization.json.WMJSONSerializer')
            mentions_json = ser.toJsonStr(mentions)
        elif format == 'json_ld':
            # We need to get a Scala Seq of annot docs here
            ml = autoclass('scala.collection.mutable.MutableList')()
            ml.appendElem(annot_doc)
            jc = autoclass(eidos_package + '.serialization.json.JLDCorpus')
            corpus = jc(ml, self.eidos_reader)
            mentions_json = corpus.toJsonStr()
        json_dict = json.loads(mentions_json)
        return json_dict
def owl_to_model(fname):
    """Return a BioPAX model object from an OWL file.

    Parameters
    ----------
    fname : str
        The name of the OWL file containing the model.

    Returns
    -------
    biopax_model : org.biopax.paxtools.model.Model
        A BioPAX model object (java object).
    """
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        file_is = autoclass('java.io.FileInputStream')(fname)
    except JavaException:
        logger.error('Could not open data file %s' % fname)
        return
    try:
        biopax_model = io.convertFromOWL(file_is)
    except JavaException as e:
        logger.error('Could not convert data file %s to BioPax model' % fname)
        logger.error(e)
        return

    file_is.close()

    return biopax_model
示例#6
0
def _run_pc_query(query_type, gene_names, neighbor_limit=1):
    cpath_client = autoclass('cpath.client.CPathClient').\
        newInstance('http://www.pathwaycommons.org/pc2/')
    query = cpath_client.createGraphQuery()
    query.kind(query_type)
    query.sources(gene_names)
    query.organismFilter(['h**o sapiens'])
    query.mergeEquivalentInteractions(True)
    query.limit(autoclass('java.lang.Integer')(neighbor_limit))
    # Execute query
    model = query.result()
    return model
示例#7
0
def _run_pc_query(query_type, source_genes, target_genes=None, neighbor_limit=1):
    cpath_client = autoclass('cpath.client.CPathClient').\
        newInstance('http://www.pathwaycommons.org/pc2/')
    query = cpath_client.createGraphQuery()
    query.kind(query_type)
    query.sources(source_genes)
    query.targets(target_genes)
    query.organismFilter(['h**o sapiens'])
    query.mergeEquivalentInteractions(True)
    query.limit(autoclass('java.lang.Integer')(neighbor_limit))
    # Execute query
    model = query.result()
    return model
示例#8
0
    def process_text(self, text, format='json'):
        """Return a mentions JSON object given text.

        Parameters
        ----------
        text : str
            Text to be processed.
        format : str
            The format of the output to produce, one of "json" or "json_ld".
            Default: "json"

        Returns
        -------
        json_dict : dict
            A JSON object of mentions extracted from text.
        """
        if self.eidos_reader is None:
            self.initialize_reader()
        default_arg = lambda x: autoclass('scala.Some')(x)
        today = datetime.date.today().strftime("%Y-%m-%d")
        fname = 'default_file_name'

        annot_doc = self.eidos_reader.extractFromText(
            text,
            True,  # keep text
            False,  # CAG-relevant only
            default_arg(today),  # doc creation time
            default_arg(fname)  # file name
        )
        if format == 'json':
            mentions = annot_doc.odinMentions()
            ser = autoclass(eidos_package +
                            '.serialization.json.WMJSONSerializer')
            mentions_json = ser.toJsonStr(mentions)
        elif format == 'json_ld':
            # We need to get a Scala Seq of annot docs here
            ml = _list_to_seq([annot_doc])
            # We currently do not need toinstantiate the adjective grounder
            # if we want to reinstate it, we would need to do the following
            # ag = EidosAdjectiveGrounder.fromConfig(
            #   EidosSystem.defaultConfig.getConfig("adjectiveGrounder"))
            # We now create a JSON-LD corpus
            jc = autoclass(eidos_package + '.serialization.json.JLDCorpus')
            corpus = jc(ml)
            # Finally, serialize the corpus into JSON string
            mentions_json = corpus.toJsonStr()
        json_dict = json.loads(mentions_json)
        return json_dict
示例#9
0
def model_to_owl(model, fname):
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        fileOS = autoclass('java.io.FileOutputStream')(fname)
    except JavaException:
        print 'Could not open data file %s' % fname
        return
    l3_factory = autoclass('org.biopax.paxtools.model.BioPAXLevel').L3.getDefaultFactory()
    model_out = l3_factory.createModel()
    for r in model.getObjects().toArray():
        model_out.add(r)
    io.convertToOWL(model_out, fileOS)

    fileOS.close()
示例#10
0
def process_nxml(file_name, use_tempdir=False, offline=False):
    if offline:
        base = os.path.basename(file_name)
        file_id = os.path.splitext(base)[0]
        if use_tempdir:
            tmp_dir = tempfile.mkdtemp()
        else:
            tmp_dir = '.'
        try:
            paper_reader = autoclass('edu.arizona.sista.reach.ReadPaper')
            paper_reader.main([file_name, tmp_dir])
        except JavaException:
            print 'Could not process file %s.' % file_name
            return None
        json_file_name = os.path.join(tmp_dir, file_id + '.uaz.events.json')
        return process_json_file(json_file_name)
    else:
        url = 'http://agathon.sista.arizona.edu:8080/odinweb/api/nxml'
        txt = open(file_name, 'rt').read()
        req = urllib2.Request(url, data=urllib.urlencode({'nxml': txt}))
        res = urllib2.urlopen(req)
        json_str = res.read()
        with open('reach_output.json', 'wt') as fh:
            fh.write(json_str)
        json_dict = json.loads(json_str)
        return process_json_str(json_str, events_only=False)
示例#11
0
def autoclass_robust(path):
    try:
        cl = autoclass(path)
    except JavaException:
        print 'Could not instantiate ' + path
        return None
    return cl
示例#12
0
def _autoclass_robust(path):
    try:
        cl = autoclass(path)
    except JavaException:
        logger.error('Could not instantiate ' + path)
        return None
    return cl
示例#13
0
def model_to_owl(model, fname):
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        fileOS = autoclass('java.io.FileOutputStream')(fname)
    except JavaException:
        print 'Could not open data file %s' % fname
        return
    l3_factory = autoclass('org.biopax.paxtools.model.BioPAXLevel').L3.getDefaultFactory()
    model_out = l3_factory.createModel()
    for r in model.getObjects().toArray():
        model_out.add(r)
    io.convertToOWL(model_out, fileOS)

    fileOS.close()
示例#14
0
def _autoclass_robust(path):
    try:
        cl = autoclass(path)
    except JavaException:
        logger.error('Could not instantiate ' + path)
        return None
    return cl
示例#15
0
def autoclass_robust(path):
    try:
        cl = autoclass(path)
    except JavaException:
        print 'Could not instantiate ' + path
        return None
    return cl
示例#16
0
def owl_to_model(fname):
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        file_is = autoclass('java.io.FileInputStream')(fname)
    except JavaException:
        print 'Could not open data file %s' % fname
        return
    try:
        biopax_model = io.convertFromOWL(file_is)
    except JavaException:
        print 'Could not convert data file %s to BioPax model' % data_file
        return

    file_is.close()

    return biopax_model
示例#17
0
def owl_to_model(fname):
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)

    try:
        file_is = autoclass('java.io.FileInputStream')(fname)
    except JavaException:
        print 'Could not open data file %s' % fname
        return
    try:
        biopax_model = io.convertFromOWL(file_is)
    except JavaException:
        print 'Could not convert data file %s to BioPax model' % data_file
        return

    file_is.close()

    return biopax_model
示例#18
0
    def get_api_ruler(self):
        """Return the existing reader if it exists or launch a new one.

        Returns
        -------
        api_ruler : edu.arizona.sista.reach.apis.ApiRuler
            An instance of the REACH ApiRuler class (java object).
        """
        if self.api_ruler is None:
            try:
                self.api_ruler =\
                    autoclass('edu.arizona.sista.reach.apis.ApiRuler')
            except JavaException:
                try:
                    autoclass('java.lang.String')
                except JavaException:
                    pass
                return None
        return self.api_ruler
示例#19
0
def owl_str_to_model(owl_str):
    """Return a BioPAX model object from an OWL string.

    Parameters
    ----------
    owl_str : str
        The model as an OWL string.

    Returns
    -------
    biopax_model : org.biopax.paxtools.model.Model
        A BioPAX model object (java object).
    """
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)
    bais = autoclass('java.io.ByteArrayInputStream')
    scs = autoclass('java.nio.charset.StandardCharsets')
    jstr = autoclass('java.lang.String')
    istream = bais(owl_str)
    biopax_model = io.convertFromOWL(istream)
    return biopax_model
示例#20
0
def owl_str_to_model(owl_str):
    """Return a BioPAX model object from an OWL string.

    Parameters
    ----------
    owl_str : str
        The model as an OWL string.

    Returns
    -------
    biopax_model : org.biopax.paxtools.model.Model
        A BioPAX model object (java object).
    """
    io_class = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
    io = io_class(autoclass('org.biopax.paxtools.model.BioPAXLevel').L3)
    bais = autoclass('java.io.ByteArrayInputStream')
    scs = autoclass('java.nio.charset.StandardCharsets')
    jstr = autoclass('java.lang.String')
    istream = bais(owl_str)
    biopax_model = io.convertFromOWL(istream)
    return biopax_model
示例#21
0
    def get_api_ruler(self):
        """Return the existing reader if it exists or launch a new one.

        Returns
        -------
        api_ruler : org.clulab.reach.apis.ApiRuler
            An instance of the REACH ApiRuler class (java object).
        """
        if self.api_ruler is None:
            try:
                self.api_ruler = \
                    autoclass('org.clulab.reach.export.apis.ApiRuler')
            except JavaException:
                # This second autoclass is needed because of a jnius
                # issue in which the first JavaException is not raised.
                try:
                    autoclass('java.lang.String')
                except JavaException as e:
                    logger.error(e)
                    pass
                return None
        return self.api_ruler
示例#22
0
    def process_text(self, text):
        """Return a mentions JSON object given text.

        Parameters
        ----------
        text : str
            Text to be processed.

        Returns
        -------
        json_dict : dict
            A JSON object of mentions extracted from text.
        """
        if self.eidos_reader is None:
            eidos = autoclass('org.clulab.wm.AgroSystem')
            self.eidos_reader = eidos(autoclass('java.lang.Object')())

        mentions = self.eidos_reader.extractFrom(text)
        ser = autoclass('org.clulab.wm.serialization.json.WMJSONSerializer')
        mentions_json = ser.toJsonStr(mentions)
        json_dict = json.loads(mentions_json)
        return json_dict
示例#23
0
    def get_api_ruler(self):
        """Return the existing reader if it exists or launch a new one.

        Returns
        -------
        api_ruler : org.clulab.reach.apis.ApiRuler
            An instance of the REACH ApiRuler class (java object).
        """
        if self.api_ruler is None:
            try:
                self.api_ruler = \
                    autoclass('org.clulab.reach.export.apis.ApiRuler')
            except JavaException:
                # This second autoclass is needed because of a jnius
                # issue in which the first JavaException is not raised.
                try:
                    autoclass('java.lang.String')
                except JavaException as e:
                    logger.error(e)
                    pass
                return None
        return self.api_ruler
示例#24
0
    def get_api_ruler(self):
        """Return the existing reader if it exists or launch a new one.

        Returns
        -------
        api_ruler : org.clulab.reach.apis.ApiRuler
            An instance of the REACH ApiRuler class (java object).
        """
        if self.api_ruler is None:
            try:
                self.api_ruler = \
                    autoclass('org.clulab.reach.export.apis.ApiRuler')
            except JavaException as e:
                raise ReachOfflineReadingError(e)
        return self.api_ruler
示例#25
0
    def get_api_ruler(self):
        """Return the existing reader if it exists or launch a new one.

        Returns
        -------
        api_ruler : org.clulab.reach.apis.ApiRuler
            An instance of the REACH ApiRuler class (java object).
        """
        if self.api_ruler is None:
            try:
                self.api_ruler = \
                    autoclass('org.clulab.reach.export.apis.ApiRuler')
            except JavaException as e:
                raise ReachOfflineReadingError(e)
        return self.api_ruler
示例#26
0
def process_nxml(file_name, use_tempdir=False):
    base = os.path.basename(file_name)
    file_id = os.path.splitext(base)[0]
    if use_tempdir:
        tmp_dir = tempfile.mkdtemp()
    else:
        tmp_dir = '.'
    try:
        paper_reader = autoclass('edu.arizona.sista.bionlp.ReadPaper')
        paper_reader.main([file_name, tmp_dir, _nxml_fries_path])
    except JavaException:
        print 'Could not process file %s.' % file_name
        return None

    json_file_name = os.path.join(tmp_dir, file_id + '.uaz.events.json')
    return process_json_file(json_file_name)
示例#27
0
def process_nxml(file_name, use_tempdir=False, offline=False):
    if offline:
        try:
            api_ruler = autoclass('edu.arizona.sista.reach.apis.ApiRuler')
            result_map = api_ruler.annotateNxml(file_name, 'fries')
        except JavaException:
            print 'Could not process file %s.' % file_name
            return None
        json_str = result_map.get('resultJson')
    else:
        url = 'http://agathon.sista.arizona.edu:8080/odinweb/api/nxml'
        txt = open(file_name, 'rt').read()
        req = urllib2.Request(url, data=urllib.urlencode({'nxml': txt}))
        res = urllib2.urlopen(req)
        json_str = res.read()
    with open('reach_output.json', 'wt') as fh:
        fh.write(json_str)
    return process_json_str(json_str)
示例#28
0
def process_nxml(file_name, use_tempdir=False, offline=False):
    if offline:
        try:
            api_ruler = autoclass('edu.arizona.sista.reach.apis.ApiRuler')
            result_map = api_ruler.annotateNxml(file_name, 'fries')
        except JavaException:
            print 'Could not process file %s.' % file_name
            return None
        json_str = result_map.get('resultJson')
    else:
        url = 'http://agathon.sista.arizona.edu:8080/odinweb/api/nxml'
        txt = open(file_name, 'rt').read()
        req = urllib2.Request(url, data=urllib.urlencode({'nxml': txt}))
        res = urllib2.urlopen(req)
        json_str = res.read()
    with open('reach_output.json', 'wt') as fh:
        fh.write(json_str)
    return process_json_str(json_str)
示例#29
0
    def process_text(self, text, format='json'):
        """Return a mentions JSON object given text.

        Parameters
        ----------
        text : str
            Text to be processed.
        format : str
            The format of the output to produce, one of "json" or "json_ld".
            Default: "json"

        Returns
        -------
        json_dict : dict
            A JSON object of mentions extracted from text.
        """
        if self.eidos_reader is None:
            eidos = autoclass(eidos_package + '.EidosSystem')
            self.eidos_reader = eidos(autoclass('java.lang.Object')())

        default_arg = lambda x: autoclass('scala.Some')(x)
        today = datetime.date.today().strftime("%Y-%m-%d")
        fname = 'default_file_name'

        annot_doc = self.eidos_reader.extractFromText(
            text,
            True,  # keep text
            False,  # CAG-relevant only
            default_arg(today),  # doc creation time
            default_arg(fname)  # file name
        )
        if format == 'json':
            mentions = annot_doc.odinMentions()
            ser = autoclass(eidos_package +
                            '.serialization.json.WMJSONSerializer')
            mentions_json = ser.toJsonStr(mentions)
        elif format == 'json_ld':
            # We need to get a Scala Seq of annot docs here
            ml = autoclass('scala.collection.mutable.MutableList')()
            # We add the document to the mutable list
            ml.appendElem(annot_doc)
            # We instantiate the adjective grounder
            ag = self.eidos_reader.loadableAttributes().adjectiveGrounder()
            # We now create a JSON-LD corpus
            jc = autoclass(eidos_package + '.serialization.json.JLDCorpus')
            corpus = jc(ml, ag)
            # Finally, serialize the corpus into JSON string
            mentions_json = corpus.toJsonStr()
        json_dict = json.loads(mentions_json)
        return json_dict
示例#30
0
def test_cpath_autoclass():
    autoclass('cpath.client.CPathClient')
示例#31
0
def test_biopaxpattern_autoclass():
    autoclass('org.biopax.paxtools.pattern.PatternBox')
示例#32
0
def test_paxtools_autoclass():
    autoclass('org.biopax.paxtools.impl.level3.ProteinImpl')
示例#33
0
 def initialize_reader(self):
     """Instantiate the Eidos reader attribute of this reader."""
     eidos = autoclass(eidos_package + '.EidosSystem')
     self.eidos_reader = eidos()
示例#34
0
def process_pc_pathsbetween(gene_names, neighbor_limit=1):
    query_type = autoclass('cpath.service.GraphType').PATHSBETWEEN
    model = _run_pc_query(query_type, gene_names, None, neighbor_limit)
    if model is not None:
        return process_model(model)
示例#35
0
def process_pc_pathsbetween(gene_names, neighbor_limit=1):
    query_type = autoclass('cpath.service.GraphType').PATHSBETWEEN
    model = _run_pc_query(query_type, gene_names, None, neighbor_limit)
    if model is not None:
        return process_model(model)
示例#36
0
def process_pc_pathsfromto(source_genes, target_genes, neighbor_limit=1):
    query_type = autoclass('cpath.service.GraphType').PATHSFROMTO
    model = _run_pc_query(query_type, source_genes, target_genes,
                          neighbor_limit)
    if model is not None:
        return process_model(model)
示例#37
0
def test_cpath_autoclass():
    autoclass('cpath.client.CPathClient')
示例#38
0
def test_biopaxpattern_autoclass():
    autoclass('org.biopax.paxtools.pattern.PatternBox')
示例#39
0
def test_paxtools_autoclass():
    autoclass('org.biopax.paxtools.impl.level3.ProteinImpl')
示例#40
0
def process_pc_neighborhood(gene_names, neighbor_limit=1):
    query_type = autoclass('cpath.service.GraphType').NEIGHBORHOOD
    model = _run_pc_query(query_type, gene_names, None, neighbor_limit)
    if model is not None:
        return process_model(model)
示例#41
0
def process_pc_neighborhood(gene_names, neighbor_limit=1):
    query_type = autoclass('cpath.service.GraphType').NEIGHBORHOOD
    model = _run_pc_query(query_type, gene_names, None, neighbor_limit)
    if model is not None:
        return process_model(model)
示例#42
0
from indra.java_vm import autoclass, cast
import heapq
from .sbgn import get_default_bbox

DEFAULT_MAX_CONVERSIONS = 20
REACTOME_NAME = 'reactome'
CTD_NAME = 'ctd'
PID_NAME = 'pid'
PANTHER_NAME = 'panther'

JHashSet = autoclass('java.util.HashSet')
JString = autoclass('java.lang.String')
JL3ToSBGNPDConverter = autoclass('org.biopax.paxtools.io.sbgn.L3ToSBGNPDConverter')
JByteArrayOutputStream = autoclass('java.io.ByteArrayOutputStream')
JStandardCharsets = autoclass('java.nio.charset.StandardCharsets')
JCompleter = autoclass('org.biopax.paxtools.controller.Completer')
JSimpleEditorMap = autoclass('org.biopax.paxtools.controller.SimpleEditorMap')
JCloner = autoclass('org.biopax.paxtools.controller.Cloner')
JBioPAXLevel = autoclass('org.biopax.paxtools.model.BioPAXLevel')
JSimpleIOHandler = autoclass('org.biopax.paxtools.io.SimpleIOHandler')
JModel = autoclass('org.biopax.paxtools.model.Model')
JConversion = autoclass('org.biopax.paxtools.model.level3.Conversion')
JByteArrayInputStream = autoclass('java.io.ByteArrayInputStream')
JBbox = autoclass('org.sbgn.bindings.Bbox')
JMarshaller = autoclass('javax.xml.bind.Marshaller')
JAXBContext = autoclass('javax.xml.bind.JAXBContext')
JBoolean = autoclass('java.lang.Boolean')

def datasource_score(jConversion):
    ds = get_datasource(jConversion)
    reverse_importance_order = [PANTHER_NAME, PID_NAME, CTD_NAME, REACTOME_NAME]
示例#43
0
def process_pc_pathsfromto(source_genes, target_genes, neighbor_limit=1):
    query_type = autoclass('cpath.service.GraphType').PATHSFROMTO
    model = _run_pc_query(query_type, source_genes, target_genes, neighbor_limit)
    if model is not None:
        return process_model(model)
示例#44
0
import sys
import os
from os.path import join, dirname, abspath
from indra import preassembler
from indra.sources import eidos
from indra.sources.hume.make_hume_tsv import make_file as mht
from indra.sources.sofia.make_sofia_tsv import make_file as mst
from indra.java_vm import autoclass

eidos_package = 'org.clulab.wm.eidos'

if __name__ == '__main__':
    sofia_ont_path = sys.argv[1]
    hume_path = 'hume_ontology_examples.tsv'
    mht(hume_path)
    sofia_path = 'sofia_ontology_examples.tsv'
    mst(sofia_ont_path, sofia_path)

    om = autoclass(eidos_package + '.apps.OntologyMapper')
    eidos = autoclass(eidos_package + '.EidosSystem')
    es = eidos(autoclass('java.lang.Object')())

    example_weight = 0.8
    parent_weight = 0.1
    topn = 10
    table_str = om.mapOntologies(es, hume_path, sofia_path, example_weight,
                                 parent_weight, topn)
    with open(join(dirname(abspath(__file__)), os.pardir, 'resources',
                   'wm_ontomap.tsv'), 'w') as fh:
        fh.write(table_str)
示例#45
0
import os
from os.path import join, dirname, abspath
from indra import preassembler
from indra.sources import eidos
from indra.sources.hume.make_hume_tsv import make_file as mht
from indra.sources.sofia.make_sofia_tsv import make_file as mst
from indra.java_vm import autoclass

eidos_package = 'org.clulab.wm.eidos'

if __name__ == '__main__':
    sofia_ont_path = sys.argv[1]
    hume_path = 'hume_ontology_examples.tsv'
    mht(hume_path)
    sofia_path = 'sofia_ontology_examples.tsv'
    mst(sofia_ont_path, sofia_path)

    om = autoclass(eidos_package + '.apps.OntologyMapper')
    eidos = autoclass(eidos_package + '.EidosSystem')
    es = eidos(autoclass('java.lang.Object')())

    example_weight = 0.8
    parent_weight = 0.1
    topn = 10
    table_str = om.mapOntologies(es, hume_path, sofia_path, example_weight,
                                 parent_weight, topn)
    with open(
            join(dirname(abspath(__file__)), os.pardir, 'resources',
                 'wm_ontomap.tsv'), 'w') as fh:
        fh.write(table_str)
示例#46
0
def _list_to_seq(lst):
    """Return a scala.collection.Seq from a Python list."""
    ml = autoclass('scala.collection.mutable.MutableList')()
    for element in lst:
        ml.appendElem(element)
    return ml