Ejemplo n.º 1
0
    def test_build_meta_failure(self):
        p1, p2 = Pipeline(), Pipeline()

        p = Pipeline._build_meta('wrong', [p1, p2])

        with self.assertRaises(MetaValueError):
            p(BELGraph())
Ejemplo n.º 2
0
 def test_serialize_file(self):
     p = Pipeline.from_functions(['enrich_protein_and_rna_origins'])
     sio = StringIO()
     p.dump(sio)
     sio.seek(0)
     p_reconstituted = Pipeline.load(sio)
     self.assertEqual(p.protocol, p_reconstituted.protocol)
Ejemplo n.º 3
0
 def test_serialize_file(self):
     p = Pipeline.from_functions(['infer_central_dogma'])
     sio = StringIO()
     p.dump(sio)
     sio.seek(0)
     p_reconstituted = Pipeline.load(sio)
     self.assertEqual(p.protocol, p_reconstituted.protocol)
Ejemplo n.º 4
0
    def test_extend(self):
        p1 = Pipeline.from_functions(['enrich_protein_and_rna_origins'])
        self.assertEqual(1, len(p1))

        p2 = Pipeline.from_functions(['remove_pathologies'])
        p1.extend(p2)

        self.assertEqual(2, len(p1))
Ejemplo n.º 5
0
    def test_extend(self):
        p1 = Pipeline.from_functions(['infer_central_dogma'])
        self.assertEqual(1, len(p1))

        p2 = Pipeline.from_functions(['remove_pathologies'])
        p1.extend(p2)

        self.assertEqual(2, len(p1))
Ejemplo n.º 6
0
    def test_pipeline_by_function(self):
        pipeline = Pipeline.from_functions([
            enrich_protein_and_rna_origins,
        ])
        result = pipeline(self.graph)

        self.assertEqual(32, result.number_of_nodes())

        for node in self.graph:
            self.assertIn(node, result)

        self.check_original_unchanged()
Ejemplo n.º 7
0
    def test_pipeline_by_string(self):
        pipeline = Pipeline.from_functions([
            'infer_central_dogma',
        ])
        result = pipeline(self.graph)

        self.assertEqual(32, result.number_of_nodes())

        for node in self.graph:
            self.assertIn(node, result)

        self.check_original_unchanged()
Ejemplo n.º 8
0
 def test_serialize_string(self):
     p = Pipeline.from_functions(['enrich_protein_and_rna_origins'])
     s = p.dumps()
     p_reconstituted = Pipeline.loads(s)
     self.assertEqual(p.protocol, p_reconstituted.protocol)
Ejemplo n.º 9
0
    def test_append(self):
        pipeline = Pipeline()
        self.assertEqual(0, len(pipeline))

        pipeline.append('enrich_protein_and_rna_origins')
        self.assertEqual(1, len(pipeline))
Ejemplo n.º 10
0
 def test_fail_add(self):
     pipeline = Pipeline()
     with self.assertRaises(MissingPipelineFunctionError):
         pipeline.append('missing function')
Ejemplo n.º 11
0
    def test_get_function_failure(self):
        p = Pipeline()

        with self.assertRaises(MissingPipelineFunctionError):
            p._get_function('nonsense name')
Ejemplo n.º 12
0
 def test_append_invalid(self):
     """Test when an invalid type is given to a :class:`pybel.struct.Pipeline`."""
     p = Pipeline()
     with self.assertRaises(TypeError):
         p.append(4)
Ejemplo n.º 13
0
from .tools_compat import calculate_error_by_annotation, get_tools_version, summarize_completeness
from .utils import SecurityConfigurableBlueprint as Blueprint, calculate_overlap_info
from .version import get_version as get_bel_commons_version

__all__ = [
    'ui_blueprint',
]

logger = logging.getLogger(__name__)

ui_blueprint = Blueprint('ui', __name__)

time_instantiated = str(datetime.datetime.now())
extract_useful_subgraph = Pipeline.from_functions([
    remove_pathologies,
    remove_associations,
    collapse_to_genes,
    remove_isolated_nodes,
])


def _format_big_number(n: int) -> str:
    if n > 1000000:
        return '{}M'.format(int(round(n / 1000000)))
    elif n > 1000:
        return '{}K'.format(int(round(n / 1000)))
    else:
        return str(n)


def redirect_to_view_explorer_query(query: Query) -> flask.Response:
    """Return the response for the biological network explorer in a given query to :func:`view_explorer_query`."""
Ejemplo n.º 14
0
 def test_serialize_string(self):
     p = Pipeline.from_functions(['infer_central_dogma'])
     s = p.dumps()
     p_reconstituted = Pipeline.loads(s)
     self.assertEqual(p.protocol, p_reconstituted.protocol)
Ejemplo n.º 15
0
    def test_append(self):
        pipeline = Pipeline()
        self.assertEqual(0, len(pipeline))

        pipeline.append('infer_central_dogma')
        self.assertEqual(1, len(pipeline))