Exemple #1
0
 def test_remove_parent_child_and_parent_and_sibling_in_remain(self):
     # given
     remove = pandas.DataFrame({
         'id1': ['a'],
         'edgeType': [EdgeType.GENE_REACTION_GENE],
         'id2': ["0"],
         'qscore': "100",
         'value': list('x')
     })
     remain = pandas.DataFrame({
         'id1': ['a', 'a', 'a'],
         'edgeType': [
             EdgeType.GENE_GENE, EdgeType.GENE_EXPRESSION_GENE,
             EdgeType.GENE_REACTION_GENE
         ],
         'id2': ["0", "0", "0"],
         'qscore': [100.0, 50, 20],
         'value':
         list('xxx')
     })
     # when
     result = utils.remove_parent_duplicates_and_reverses(remove_set=remove,
                                                          remain_set=remain)
     # then
     true_result = pandas.DataFrame({
         'id1': ['a', 'a'],
         'edgeType':
         [EdgeType.GENE_EXPRESSION_GENE, EdgeType.GENE_REACTION_GENE],
         'id2': ["0", "0"],
         'qscore': [50, 20],
         'value':
         list('xx')
     })
     np.testing.assert_array_equal(true_result.values, result.values)
Exemple #2
0
 def test_remove_parent_child_and_parent_and_sibling_in_remain(self):
     # given
     remove = pandas.DataFrame({
         "id1": ["a"],
         "edgeType": [EdgeType.GENE_REACTION_GENE],
         "id2": ["0"],
         "qscore": "100",
         "value": list("x")
     })
     remain = pandas.DataFrame({
         "id1": ["a", "a", "a"],
         "edgeType": [
             EdgeType.GENE_GENE, EdgeType.GENE_EXPRESSION_GENE,
             EdgeType.GENE_REACTION_GENE
         ],
         "id2": ["0", "0", "0"],
         "qscore": [100.0, 50, 20],
         "value":
         list("xxx"),
     })
     # when
     result = utils.remove_parent_duplicates_and_reverses(remove_set=remove,
                                                          remain_set=remain)
     # then
     true_result = pandas.DataFrame({
         "id1": ["a", "a"],
         "edgeType":
         [EdgeType.GENE_EXPRESSION_GENE, EdgeType.GENE_REACTION_GENE],
         "id2": ["0", "0"],
         "qscore": [50, 20],
         "value":
         list("xx"),
     })
     np.testing.assert_array_equal(true_result.values, result.values)
Exemple #3
0
 def test_remove_parent_reverse_parent(self):
     #given
     remove = pandas.DataFrame({
         'id1': ['a'],
         'edgeType': [EdgeType.GENE_REACTION_GENE],
         'id2': ["0"],
         'qscore': ["a"],
         'value': list('x')
     })
     remain = pandas.DataFrame({
         'id1': ['0', 'b', 'c'],
         'edgeType':
         [EdgeType.GENE_GENE, EdgeType.GENE_GENE, EdgeType.GENE_GENE],
         'id2': ["a", "1", "2"],
         'qscore': [100.0, 50, 20],
         'value':
         list('xxy')
     })
     #when
     result = utils.remove_parent_duplicates_and_reverses(remove_set=remove,
                                                          remain_set=remain)
     #then
     true_result = pandas.DataFrame({
         'id1': ['b', 'c'],
         'edgeType': [EdgeType.GENE_GENE, EdgeType.GENE_GENE],
         'id2': ["1", "2"],
         'qscore': [50, 20],
         'value':
         list('xy')
     })
     np.testing.assert_array_equal(true_result.values, result.values)
Exemple #4
0
 def test_remove_parent_parent_in_remain(self):
     # given
     remove = pandas.DataFrame({
         "id1": ["a"],
         "edgeType": [EdgeType.GENE_REACTION_GENE],
         "id2": ["0"],
         "qscore": "100",
         "value": [1]
     })
     remain = pandas.DataFrame({
         "id1": ["a", "b", "c"],
         "edgeType":
         [EdgeType.GENE_GENE, EdgeType.GENE_GENE, EdgeType.GENE_GENE],
         "id2": ["0", "1", "2"],
         "qscore": [120.0, 50, 20],
         "value": [1, 1, 0],
     })
     # when
     result = utils.remove_parent_duplicates_and_reverses(remove_set=remove,
                                                          remain_set=remain)
     # then
     true_result = pandas.DataFrame({
         "id1": ["b", "c"],
         "edgeType": [EdgeType.GENE_GENE, EdgeType.GENE_GENE],
         "id2": ["1", "2"],
         "qscore": [50, 20],
         "value": [1, 0],
     })
     np.testing.assert_array_equal(true_result.values, result.values)