async def show(self, group_id): result = await self.client( functions.messages.GetScheduledHistoryRequest(peer=group_id, hash=0)) messages = result.messages processed_messages = [] for message in messages: processed_messages.append({ 'date': str(message.date)[:16], 'message': message.message[:60].replace('\n', ' ') }) table_formatter = TableFormatter() table_formatter.print_table(processed_messages)
def cross_raghavan(file_name, reverse=False): print "Cross Raghavan running..." files = [file_name] our_tables = [(name, "our_files/%s" % name) for name in files] article_tables = [("s5", "final_format/s5_directed.table"), ("s6", "final_format/s6_directed.table"), ("s7", "final_format/s7_directed.table")] if not reverse: TableCrosser(our_tables, article_tables).cross_tables(1000, "results/raghavan") else: TableCrosser(our_tables, article_tables).cross_tables_reverse(100000000, "results/raghavan/reverse") print "Formatting file..." TableFormatter.split_reverse_rows(TableLoader, "results/raghavan/reverse/%s.table" % file_name) print "Done."
def cross_bilusic(file_name, reverse=False): print "Cross Bilusic running..." files = [file_name] our_tables = [(name, "our_files/%s" % name) for name in files] article_tables = [("2014RNABIOL0069R_TableS1", "bilusic/final/2014RNABIOL0069R_TableS1.table"), ("2014RNABIOL0069R_TableS2", "bilusic/final/2014RNABIOL0069R_TableS2.table"), ("2014RNABIOL0069R_TableS3", "bilusic/final/2014RNABIOL0069R_TableS3.table"), ("2014RNABIOL0069R_TableS4", "bilusic/final/2014RNABIOL0069R_TableS4.table")] if not reverse: TableCrosser(our_tables, article_tables).cross_tables(1000, "results/bilusic", 20) else: TableCrosser(our_tables, article_tables).cross_tables_reverse(100000000, "results/bilusic/reverse", 20) print "Formatting file..." TableFormatter.split_reverse_rows(TableLoader, "results/bilusic/reverse/%s.table" % file_name) print "Done."
def cross_zhang(file_name, reverse=False): print "Cross Zhang running..." files = [file_name] our_tables = [(name, "our_files/%s" % name) for name in files] article_tables = [("zhang2013_s3_sheet_2008", "zhang/final/Table-s3-zhang-2013-sheet2008.table"), ("zhang2013_s3_sheet_2009", "zhang/final/Table-s3-zhang-2013-sheet2009.table"), ("zhang2013_s4_sheet_2008", "zhang/final/Table-s4-zhang-2013-sheet2008.table"), ("zhang2013_s4_sheet_2009", "zhang/final/Table-s4-zhang-2013-sheet2009.table")] if not reverse: TableCrosser(our_tables, article_tables).cross_tables(1000, "results/zhang") else: TableCrosser(our_tables, article_tables).cross_tables_reverse(100000000, "results/zhang/reverse") print "Formatting file..." TableFormatter.split_reverse_rows(TableLoader, "results/zhang/reverse/%s.table" % file_name) print "Done."
files = [ "assign-type-to-all-chimeras-of-Iron_limitation_CL_FLAG207_208_305_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-Log_phase_CL_FLAG101-104_108_109_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-MG_hfq-WT101_cutadapt_bwa.bam_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-MG_hfq-wt202_CL_Stationary_cutadapt_bwa.bam_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-Stationary_CL_FLAG209_210_312_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-signif-chimeras-of-Iron_limitation_CL_FLAG207_208_305_all_fragments_l25.txt_sig_interactions.with-type", "assign-type-to-signif-chimeras-of-Log_phase_CL_FLAG101-104_108_109_all_fragments_l25.txt_sig_interactions.with-type", "assign-type-to-signif-chimeras-of-Stationary_CL_FLAG209_210_312_all_fragments_l25.txt_sig_interactions.with-type", "assign-type-to-single-counts-of-Iron_limitation_CL_FLAG207_208_305_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-Log_phase_CL_FLAG101-104_108_109_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-MG_hfq-WT101_cutadapt_bwa.bam_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-MG_hfq-wt202_CL_Stationary_cutadapt_bwa.bam_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-Stationary_CL_FLAG209_210_312_all_fragments_l25.txt_single_counts.with-type", ] from TableCrosser import cross_zhang, cross_raghavan, cross_bilusic, cross_tss, cross_lybecker from TableFormatter import TableFormatter from TableLoader import TableLoader for name in files: print name print "*" * 100 # TableFormatter.split_reverse_rows(TableLoader, "results/raghavan/reverse/%s.table" % name) # TableFormatter.split_reverse_rows(TableLoader, "results/zhang/reverse/%s.table" % name) TableFormatter.split_reverse_rows(TableLoader, "results/bilusic/reverse/%s.table" % name) # TableFormatter.split_reverse_rows(TableLoader, "results/tss/reverse/%s.table" % name) # TableFormatter.split_reverse_rows(TableLoader, "results/lybecker/reverse/%s.table" % name)
def format_our_single(db_cursor, output): header = ["our_name", "ecocyc_id", "type", "our_start", "our_end", "result", "their_name", "their_start", "their_end", "their_strand", "distance", "interactions", "odds_ratio"] fl = open(output, "wb") fl.write("%s\n" % "\t".join(header)) # keep going over the results until done row = db_cursor.fetchone() if row is not None: print row.keys() names_to_data = {} while row is not None: values_list = [] if row["match_first"]: values = [row["rna1_name"], row["rna1_ecocyc_id"], row["first_type"], row["our.start_1"], row["our.end_1"], "true", row["name"], row["start_1"], row["end_1"], row["strand_1"], row["distance_1"], row["interactions"], row["odds_ratio"]] values_list.append(values) if row["match_second"]: values = [row["rna2_name"], row["rna2_ecocyc_id"], row["second_type"], row["start_2"], row["end_2"], "true", row["name"], row["start_1"], row["end_1"], row["strand_2"], row["distance_2"], row["interactions"], row["odds_ratio"]] values_list.append(values) if not row["match_first"] and not row["match_second"]: if row["closest_1"] < row["closest_2"]: values = [row["rna1_name"], row["rna1_ecocyc_id"], row["first_type"], row["our.start_1"], row["our.end_1"], "false", row["name"], row["start_1"], row["end_1"], row["strand_1"], row["closest_1"], row["interactions"], row["odds_ratio"]] else: values = [row["rna2_name"], row["rna2_ecocyc_id"], row["second_type"], row["start_2"], row["end_2"], "false", row["name"], row["start_1"], row["end_1"], row["strand_2"], row["closest_2"], row["interactions"], row["odds_ratio"]] values_list.append(values) for curr_values in values_list: TableFormatter._add_names_to_data(names_to_data, curr_values) fl.write("%s\n" % "\t".join(str(val) for val in curr_values)) # print values row = db_cursor.fetchone() fl.close() TableFormatter._sort_names_to_data(names_to_data) fl = open("%s.sorted" % output, "wb") fl.write("%s\n" % "\t".join(header)) for curr in TableFormatter._sort_names_to_data(names_to_data): fl.write("%s\n" % "\t".join(str(val) for val in curr)) fl.close()
def format_our_single(db_cursor, output): header = [ "our_name", "ecocyc_id", "type", "our_start", "our_end", "result", "their_name", "their_start", "their_end", "their_strand", "distance", "interactions", "odds_ratio" ] fl = open(output, "wb") fl.write("%s\n" % "\t".join(header)) # keep going over the results until done row = db_cursor.fetchone() if row is not None: print row.keys() names_to_data = {} while row is not None: values_list = [] if row["match_first"]: values = [ row["rna1_name"], row["rna1_ecocyc_id"], row["first_type"], row["our.start_1"], row["our.end_1"], "true", row["name"], row["start_1"], row["end_1"], row["strand_1"], row["distance_1"], row["interactions"], row["odds_ratio"] ] values_list.append(values) if row["match_second"]: values = [ row["rna2_name"], row["rna2_ecocyc_id"], row["second_type"], row["start_2"], row["end_2"], "true", row["name"], row["start_1"], row["end_1"], row["strand_2"], row["distance_2"], row["interactions"], row["odds_ratio"] ] values_list.append(values) if not row["match_first"] and not row["match_second"]: if row["closest_1"] < row["closest_2"]: values = [ row["rna1_name"], row["rna1_ecocyc_id"], row["first_type"], row["our.start_1"], row["our.end_1"], "false", row["name"], row["start_1"], row["end_1"], row["strand_1"], row["closest_1"], row["interactions"], row["odds_ratio"] ] else: values = [ row["rna2_name"], row["rna2_ecocyc_id"], row["second_type"], row["start_2"], row["end_2"], "false", row["name"], row["start_1"], row["end_1"], row["strand_2"], row["closest_2"], row["interactions"], row["odds_ratio"] ] values_list.append(values) for curr_values in values_list: TableFormatter._add_names_to_data(names_to_data, curr_values) fl.write("%s\n" % "\t".join(str(val) for val in curr_values)) # print values row = db_cursor.fetchone() fl.close() TableFormatter._sort_names_to_data(names_to_data) fl = open("%s.sorted" % output, "wb") fl.write("%s\n" % "\t".join(header)) for curr in TableFormatter._sort_names_to_data(names_to_data): fl.write("%s\n" % "\t".join(str(val) for val in curr)) fl.close()
files = [ "assign-type-to-all-chimeras-of-Iron_limitation_CL_FLAG207_208_305_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-Log_phase_CL_FLAG101-104_108_109_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-MG_hfq-WT101_cutadapt_bwa.bam_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-MG_hfq-wt202_CL_Stationary_cutadapt_bwa.bam_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-all-chimeras-of-Stationary_CL_FLAG209_210_312_all_fragments_l25.txt_all_interactions.with-type", "assign-type-to-signif-chimeras-of-Iron_limitation_CL_FLAG207_208_305_all_fragments_l25.txt_sig_interactions.with-type", "assign-type-to-signif-chimeras-of-Log_phase_CL_FLAG101-104_108_109_all_fragments_l25.txt_sig_interactions.with-type", "assign-type-to-signif-chimeras-of-Stationary_CL_FLAG209_210_312_all_fragments_l25.txt_sig_interactions.with-type", "assign-type-to-single-counts-of-Iron_limitation_CL_FLAG207_208_305_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-Log_phase_CL_FLAG101-104_108_109_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-MG_hfq-WT101_cutadapt_bwa.bam_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-MG_hfq-wt202_CL_Stationary_cutadapt_bwa.bam_all_fragments_l25.txt_single_counts.with-type", "assign-type-to-single-counts-of-Stationary_CL_FLAG209_210_312_all_fragments_l25.txt_single_counts.with-type" ] from TableCrosser import cross_zhang, cross_raghavan, cross_bilusic, cross_tss, cross_lybecker from TableFormatter import TableFormatter from TableLoader import TableLoader for name in files: print name print "*" * 100 # TableFormatter.split_reverse_rows(TableLoader, "results/raghavan/reverse/%s.table" % name) # TableFormatter.split_reverse_rows(TableLoader, "results/zhang/reverse/%s.table" % name) TableFormatter.split_reverse_rows( TableLoader, "results/bilusic/reverse/%s.table" % name) # TableFormatter.split_reverse_rows(TableLoader, "results/tss/reverse/%s.table" % name) # TableFormatter.split_reverse_rows(TableLoader, "results/lybecker/reverse/%s.table" % name)