def generate_logfc_plot(self, analysis_type, essentiality_files): files = [ getattr(essentiality_files[plotfile], analysis_type).tradis_essentiality_filename for plotfile in self.plotfiles ] only_ess_files = [ getattr(essentiality_files[plotfile], analysis_type).only_essential_filename for plotfile in self.plotfiles ] annotation_files = [ essentiality_files[plotfile].embl_filename for plotfile in self.plotfiles ] mid = int(len(files) / 2) t = TradisComparison(files[:mid], files[mid:], self.verbose, self.minimum_block, only_ess_files[:mid], only_ess_files[mid:], analysis_type, self.prefix) t.run() p = PlotLog(t.output_filename, self.genome_length, self.minimum_logfc, self.pvalue, self.qvalue, self.minimum_logcpm, self.window_size, self.span_gaps, self.report_decreased_insertions, annotation_files[0]) p.construct_plot_file() renamed_csv_file = os.path.join(self.prefix, analysis_type + ".csv") renamed_plot_file = os.path.join(self.prefix, analysis_type + ".plot") shutil.copy(t.output_filename, renamed_csv_file) shutil.copy(p.output_filename, renamed_plot_file) os.remove(t.output_filename) os.remove(p.output_filename) if self.verbose: print("Comparison:\t" + renamed_csv_file) print("Plot log:\t" + renamed_plot_file) return renamed_plot_file
def test_span_gaps_block_at_end_neg(self): p = PlotLog('x', 20, 2, 0.05, 1, 4, 1, True, None) l = p.span_block_gaps([0,0,0,-9,-9,-9,0,0,0,0,0,-8,-8,-8,-8,0,0,-7,-7,-7]) self.assertEqual([0,0,0,-9,-9,-9,0,0,0,0,0,-8,-8,-8,-8,-2,-2,-7,-7,-7],l )
def test_span_gaps_nomerge_neg(self): p = PlotLog('x', 20, 2, 0.05, 1, 4, 1, True, None) l = p.span_block_gaps([0,0,0,-9,-9,-9,0,0,0,0,0,-8,-8,-8,-8,0,0,0,0,0]) self.assertEqual([0,0,0,-9,-9,-9,0,0,0,0,0,-8,-8,-8,-8,0,0,0,0,0],l )
def test_span_gaps_block_at_end(self): p = PlotLog('x', 20, 2, 0.05, 1, 4, 1, True, None) l = p.span_block_gaps([0,0,0,9,9,9,0,0,0,0,0,8,8,8,8,0,0,7,7,7]) self.assertEqual([0,0,0,9,9,9,0,0,0,0,0,8,8,8,8,2,2,7,7,7],l )
def test_span_gaps_merge(self): p = PlotLog('x', 20, 2, 0.05, 1, 4, 1, True, None) l = p.span_block_gaps([0,0,0,9,9,9,9,0,0,0,0,8,8,8,8,0,0,0,0,0]) self.assertEqual([0,0,0,9,9,9,9,2,2,2,2,8,8,8,8,0,0,0,0,0],l )