Beispiel #1
0
 def _match_disease(v: Vertex) -> bool:
     """Tests if a vertex name matches the regular expression for disease ids."""
     try:
         disease_regex.match(v.attributes()["name"])
     except TypeError:
         print(v.attributes()["name"])
         print(type(v.attributes()["name"]))
         sys.exit()
     return bool(disease_regex.match(v.attributes()["name"]))
    def get_for(cls, v: Vertex, decompiler: 'ExplorerScriptSsbDecompiler',
                parent: AbstractWriteHandler,
                vertex_that_started_block: Vertex,
                is_first_vertex_of_block: bool) -> AbstractWriteHandler:
        from explorerscript.ssb_converting.decompiler.write_handlers.foreign_label import ForeignLabelWriteHandler
        from explorerscript.ssb_converting.decompiler.write_handlers.label import LabelWriteHandler
        from explorerscript.ssb_converting.decompiler.write_handlers.label_jump import LabelJumpWriteHandler
        from explorerscript.ssb_converting.decompiler.write_handlers.simple_op import SimpleOperationWriteHandler

        if 'op' not in v.attributes():
            raise ValueError(f"Invalid Ssb vertex: {v}")
        op: SsbOperation = v['op']
        if isinstance(op, SsbLabel):
            return LabelWriteHandler(v, decompiler, parent,
                                     vertex_that_started_block,
                                     is_first_vertex_of_block)
        if isinstance(op, SsbForeignLabel):
            return ForeignLabelWriteHandler(v, decompiler, parent,
                                            vertex_that_started_block,
                                            is_first_vertex_of_block)
        if isinstance(op, SsbLabelJump):
            return LabelJumpWriteHandler(v, decompiler, parent)
        return SimpleOperationWriteHandler(v, decompiler, parent)
Beispiel #3
0
 def _is_significantly_differentiated(self, v: Vertex) -> bool:
     """In a heterogeneous network, the vertex has to be tested if it is a gene before testing if it's up or
     down regulated."""
     return self.is_gene(v) and v.attributes()['padj'] < self.max_adj_p
Beispiel #4
0
 def _match_drug(v: Vertex) -> bool:
     """Tests if a vertex name matches the regular expression for Drugbank ids. """
     return bool(drugbank_regex.match(v.attributes()["name"]))
Beispiel #5
0
 def is_disease(v: Vertex) -> bool:
     """Tests if a vertex is a disease node. """
     return v.attributes()['type'] == 'disease'
Beispiel #6
0
 def is_gene(v: Vertex) -> bool:
     """Tests if a vertex is a gene node. """
     return v.attributes()['type'] == 'gene'
Beispiel #7
0
 def is_drug(v: Vertex) -> bool:
     """Tests if a vertex is a drug node. """
     return v.attributes()['type'] == 'drug'
 def _is_downregulated_gene(self, v: Vertex) -> bool:
     return self._is_significantly_differentiated(
         v) and v.attributes()['l2fc'] < self.max_l2fc
 def _is_significantly_differentiated(self, v: Vertex) -> bool:
     return v.attributes()['padj'] < self.max_adj_p