def test_max_different_overlappers_get_all(self): dict_data = {} dict_data['1'] = {} dict_data['1']['2'] = {} dict_data['1']['2']['+'] = [] inter1 = Interval("Test1", 1, 2, "+", 50, 50, 15, 10, 75, 70) inter2 = Interval("Test2", 1, 2, "+", 50, 50, 115, 110, 175, 170) inter3 = Interval("Test3", 1, 2, "+", 50, 50, 215, 210, 275, 270) dict_data['1']['2']['+'].append(inter1) dict_data['1']['2']['+'].append(inter2) dict_data['1']['2']['+'].append(inter3) analysis = CoverageTypeAnalysis() analysis.analyse_data(dict_data, ["Test1", "Test2", "Test3"], 1, None, True) self.assertEqual(3, len(dict_data['1']['2']['+'])) result2 = Interval("Test1", 1, 2, "+", 50, 50, 115, 110, 175, 170) result3 = Interval("Test1", 1, 2, "+", 50, 50, 215, 210, 275, 270) self.assertEqual(inter1.toStringInterval(), dict_data['1']['2']['+'][0].toStringInterval()) self.assertEqual(result2.toStringInterval(), dict_data['1']['2']['+'][1].toStringInterval()) self.assertEqual(result3.toStringInterval(), dict_data['1']['2']['+'][2].toStringInterval())
def test_strict_no_fusion_different_overlappers_2_good_overlappers(self): dict_data = {} dict_data['1'] = {} dict_data['1']['2'] = {} dict_data['1']['2']['+'] = [] inter1 = Interval("Test1", 1, 2, "+", 50, 50, 15, 10, 175, 170) inter2 = Interval("Test2", 1, 2, "+", 50, 50, 115, 110, 175, 170) inter3 = Interval("Test3", 1, 2, "+", 50, 50, 215, 210, 275, 270) dict_data['1']['2']['+'].append(inter1) dict_data['1']['2']['+'].append(inter2) dict_data['1']['2']['+'].append(inter3) analysis = CoverageTypeAnalysis() analysis.analyse_data(dict_data, ["Test1", "Test2", "Test3"], 0, None, False) self.assertEqual(0, len(dict_data['1']['2']['+']))
def test_custom_equals_to_no_accept(self): dict_data = {} dict_data['1'] = {} dict_data['1']['2'] = {} dict_data['1']['2']['+'] = [] inter1 = Interval("Test1", 1, 2, "+", 50, 50, 115, 110, 175, 170) inter2 = Interval("Test2", 1, 2, "+", 50, 50, 115, 110, 175, 170) inter3 = Interval("Test3", 1, 2, "+", 50, 50, 115, 110, 175, 170) dict_data['1']['2']['+'].append(inter1) dict_data['1']['2']['+'].append(inter2) dict_data['1']['2']['+'].append(inter3) analysis = CoverageTypeAnalysis() analysis.analyse_data(dict_data, ["Test1", "Test2", "Test3"], 12, 2, False) self.assertEqual(0, len(dict_data['1']['2']['+']))
def test_max_same_overlappers(self): dict_data = {} dict_data['1'] = {} dict_data['1']['2'] = {} dict_data['1']['2']['+'] = [] inter1 = Interval("Test1", 1, 2, "+", 50, 50, 15, 10, 75, 70) inter2 = Interval("Test1", 1, 2, "+", 50, 50, 115, 110, 175, 170) inter3 = Interval("Test1", 1, 2, "+", 50, 50, 215, 210, 275, 270) dict_data['1']['2']['+'].append(inter1) dict_data['1']['2']['+'].append(inter2) dict_data['1']['2']['+'].append(inter3) analysis = CoverageTypeAnalysis() analysis.analyse_data(dict_data, ["Test1", "Test2", "Test3"], 1, None, False) self.assertEqual(1, len(dict_data['1']['2']['+'])) self.assertEqual(inter1.toStringInterval(), dict_data['1']['2']['+'][0].toStringInterval())
def test_strict_fusion_different_overlappers(self): dict_data = {} dict_data['1'] = {} dict_data['1']['2'] = {} dict_data['1']['2']['+'] = [] inter1 = Interval("Test1", 1, 2, "+", 50, 50, 15, 10, 175, 170) inter2 = Interval("Test2", 1, 2, "+", 50, 50, 115, 110, 215, 225) inter3 = Interval("Test3", 1, 2, "+", 50, 50, 150, 160, 275, 270) dict_data['1']['2']['+'].append(inter1) dict_data['1']['2']['+'].append(inter2) dict_data['1']['2']['+'].append(inter3) analysis = CoverageTypeAnalysis() analysis.analyse_data(dict_data, ["Test1", "Test2", "Test3"], 0, None, False) result1 = Interval("Test1", 1, 2, "+", 50, 50, 150, 160, 175, 170) self.assertEqual(1, len(dict_data['1']['2']['+'])) self.assertEqual(result1.toStringInterval(), dict_data['1']['2']['+'][0].toStringInterval())
def test_custom_less_than_accept(self): dict_data = {} dict_data['1'] = {} dict_data['1']['2'] = {} dict_data['1']['2']['+'] = [] inter1 = Interval("Test1", 1, 2, "+", 50, 50, 15, 10, 75, 70) inter2 = Interval("Test2", 1, 2, "+", 50, 50, 115, 110, 175, 170) inter3 = Interval("Test3", 1, 2, "+", 50, 50, 215, 210, 275, 270) dict_data['1']['2']['+'].append(inter1) dict_data['1']['2']['+'].append(inter2) dict_data['1']['2']['+'].append(inter3) analysis = CoverageTypeAnalysis() analysis.analyse_data(dict_data, ["Test1", "Test2", "Test3"], 12, 2, False) self.assertEqual(1, len(dict_data['1']['2']['+'])) result1 = Interval("Test1", 1, 2, "+", 50, 50, 215, 210, 275, 270) self.assertEqual(result1.toStringInterval(), dict_data['1']['2']['+'][0].toStringInterval())
def main(args): """Main function of the program""" parameters = Parameters() readFiles = ReadFiles() parser = parameters.complete_analyze(sys.argv[1:]) parameters.additionnalAnalysis(parser) outputWriter = OutputWriter(parser.analysis) dict_data = readFiles.readAllFiles(parser.files, "../allowed_files.csv") count = 0 for id_a in dict_data: for id_b in dict_data[id_a]: for strand in dict_data[id_a][id_b]: count = count + len(dict_data[id_a][id_b][strand]) if parser.stats is False: tools = AnalysisTools() print("=============================") if parser.analysis == "gentle": analysis = GentleTypeAnalysis() dict_data = analysis.analyse_data(dict_data) else: analysis = CoverageTypeAnalysis() if parser.analysis == "strict": dict_data = analysis.analyse_data(dict_data, parser.files, 0, None, parser.get_all) elif parser.analysis == "max": dict_data = analysis.analyse_data(dict_data, parser.files, 1, None, parser.get_all) elif parser.analysis == "custom": if parser.moreThan is not None: dict_data = analysis.analyse_data(dict_data, parser.files, 11, int(parser.moreThan), parser.get_all) elif parser.lessThan is not None: dict_data = analysis.analyse_data(dict_data, parser.files, 12, int(parser.lessThan), parser.get_all) else: dict_data = analysis.analyse_data(dict_data, parser.files, 13, int(parser.equalsTo), parser.get_all) print("=============================") if parser.no_output is False: if parser.output == "mhap": outputWriter.outputMhap(dict_data) elif parser.output == "paf": outputWriter.outputPaf(dict_data) else: print("Hisea output not implemented yet.") exit(0) else: print("No writing in an output file") # If the stat option is enabled, print some statistics about the files else: statAnalyser = StatisticsTypeAnalysis() print(statAnalyser.statistics(dict_data, parser.files))