def FF_plot(batch_id): L = Layout(batch_id) FF = FetalFraction(batch_id) FF.format_case_dict() FF.format_contol_dict() FF.form_prediction_interval() batch = Batch.query.filter(Batch.batch_id == batch_id).first() sample_db = Sample.query.filter(Sample.batch_id == batch_id) DC = DataClasifyer() DC.get_QC_warnings(sample_db) return render_template('batch_page/tab_FF.html', ## Warnings Table seq_warnings = DC.QC_warnings, ## Header batch_name = batch.batch_name, batch_id = batch_id, seq_date = batch.date, ## Plotts nr_contol_samples = FF.nr_contol_samples, predict = FF.perdiction, cases = FF.samples, control = FF.control, case_size = L.case_size, case_line = L.case_line, many_colors = L.many_colors_dict, sample_list = FF.sample_list )
def NCV18_plot(batch_id): #getting thresholds and layout DC = DataClasifyer() sample_db = Sample.query.filter(Sample.batch_id == batch_id) DC.get_QC_warnings(sample_db) L = Layout(batch_id) # Getting and formating sample and NCV data for the control samples in the plot control_normal, control_abnormal = BDF.control_NCV18() # Getting and formating sample and NCV data for the samples in the batch batch = Batch.query.filter(Batch.batch_id == batch_id).first() NCV_db = NCV.query.filter(NCV.batch_id == batch_id).all() TA = TrisAbnormality(batch_id, NCV_db) case_data = TA.make_case_data(control_normal, '18') tris_chrom_abn = TA.make_tris_chrom_abn(control_abnormal, '18') return render_template('batch_page/tab_NCV18.html', ## Warnings Table seq_warnings = DC.QC_warnings, ## Header batch_name = batch.batch_name, seq_date = batch.date, batch_id = batch_id, ## Plotts chrom = '18', case_data = case_data, tris_chrom_abn = tris_chrom_abn, case_size = L.case_size, case_line = L.case_line, abn_size = L.abn_size, abn_line = L.abn_line, abn_symbol = L.abn_symbol, ncv_abn_colors = L.ncv_abn_colors, tris_thresholds = DC.tris_thresholds)
def coverage_plot(batch_id): L = Layout(batch_id) NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer(NCV_db) DC.handle_NCV() DC.get_QC_warnings(sample_db) CP = CoveragePlot(batch_id) CP.make_cov_plot_data() return render_template('batch_page/tab_coverage.html', ## Header batch_name = batch.batch_name, seq_date = batch.date, ## Warnings Table seq_warnings = DC.QC_warnings, samp_cov_db = CP.coverage_plot, cov_colors = L.cov_colors, case_size = L.case_size, case_line = L.case_line, ## Buttons batch_id = batch_id, sample_ids = ','.join(sample.sample_ID for sample in NCV_db), sample_list = CP.sample_list)
def covX_covY(batch_id): L = Layout(batch_id) CC = CovXCovY(batch_id) CC.format_case_dict() CC.format_contol_dict() CC.format_pos_contol() batch = Batch.query.filter(Batch.batch_id == batch_id).first() sample_db = Sample.query.filter(Sample.batch_id == batch_id) DC = DataClasifyer() DC.get_QC_warnings(sample_db) return render_template('batch_page/tab_covX_covY.html', ## Warnings Table seq_warnings = DC.QC_warnings, ## Header batch_name = batch.batch_name, batch_id = batch_id, seq_date = batch.date, ## Plotts nr_contol_samples = CC.nr_contol_samples, cases = CC.samples, control = CC.control, pos_contol = CC.pos_contol, case_size = L.case_size, case_line = L.case_line, ncv_abn_colors = L.ncv_abn_colors, abn_size = L.abn_size, abn_line = L.abn_line, abn_symbol = L.abn_symbol, many_colors = L.many_colors_dict, sample_list = CC.sample_list )
def sample_page( sample_id): sample = Sample.query.filter_by(sample_ID = sample_id).first() NCV_dat = NCV.query.filter_by(sample_ID = sample_id) batch_id = sample.batch_id batch = Batch.query.filter_by(batch_id = batch_id).first() DC = DataClasifyer(NCV_dat) DC.handle_NCV() chrom_abnorm = ['T13','T18', 'T21', 'X0', 'XXX','XXY','XYY'] db_entries = {c:sample.__dict__['status_'+c].replace('\r\n', '').strip() for c in chrom_abnorm } db_entries_change = {c:sample.__dict__['status_change_'+c] for c in chrom_abnorm} return render_template('sample_page/sample_page.html', ## Header & Info Box current_user = current_user, NCV_dat = NCV_dat.first(), sample = sample, batch_id = batch_id, batch_name = batch.batch_name, batch = batch, NCV_sex = DC.NCV_sex[sample_id], NCV_warn = DC.NCV_classified[sample_id], ## Status Table sample_id = sample_id, chrom_abnorm = chrom_abnorm, db_entries = db_entries, db_entries_change = db_entries_change)
def sample_page(sample_id): sample = Sample.query.filter_by(sample_ID=sample_id).first() batch_id = sample.batch_id batch = Batch.query.filter_by(batch_id=batch_id).first() NCV_db = NCV.query.filter(NCV.batch_id == batch_id) DC = DataClasifyer() DC.handle_NCV(NCV_db) NCV_dat = NCV.query.filter_by(sample_ID=sample_id).first() chrom_abnorm = ['T13', 'T18', 'T21', 'X0', 'XXX', 'XXY', 'XYY'] db_entries = { c: sample.__dict__['status_' + c].replace('\r\n', '').strip() for c in chrom_abnorm } db_entries_change = { c: sample.__dict__['status_change_' + c] for c in chrom_abnorm } db_entries_comments = { c: sample.__dict__['comment_' + c] for c in chrom_abnorm } PP = PlottPage(batch_id) PP.make_NCV_stat() PP.make_chrom_abn() sample_state_dict = PP.sample_state_dict for state in sample_state_dict: sample_state_dict[state]['T_13'] = Sample.query.filter_by( status_T13=state) sample_state_dict[state]['T_18'] = Sample.query.filter_by( status_T18=state) sample_state_dict[state]['T_21'] = Sample.query.filter_by( status_T21=state) return render_template( 'sample_page.html', NCV_dat=NCV_dat, tris_abn=PP.tris_abn, sex_chrom_abn=PP.sex_chrom_abn, abn_status_list=[ 'Verified', 'False Positive', 'Probable', 'Suspected' ], sex_abn_colors=PP.sex_abn_colors, sample=sample, NCV_db=NCV.query.filter_by(sample_ID=sample_id).first(), batch_id=batch_id, batch_name=batch.batch_name, batch=batch, nr_validation_samps=PP.nr_validation_samps, sample_id=sample_id, chrom_abnorm=chrom_abnorm, db_entries=db_entries, db_entries_comments=db_entries_comments, db_entries_change=db_entries_change, NCV_stat=PP.NCV_stat, NCV_131821=['NCV_13', 'NCV_18', 'NCV_21'], state_dict=sample_state_dict, sex_tresholds=DC.sex_tresholds, tris_thresholds=DC.tris_thresholds, NCV_sex=DC.NCV_sex[sample_id], NCV_warn=DC.NCV_classified[sample_id])
def samples(): ncv_columns = ['include', 'comment','sample_name'] sample_columns = ['T13','T18', 'T21', 'X0', 'XXX','XXY','XYY'] filter_dict = dict.fromkeys(ncv_columns+sample_columns+['batch'],'') # making filters ncv_filters = [] sample_filters = [] batch_filter = [] if not request.args.get('clear_filters'): batch = request.args.get('batch') if batch: batch_filter.append(Batch.batch_name.contains(str(batch))) filter_dict['batch'] = batch for column in ncv_columns: NCV_filter = request.args.get(column) if NCV_filter: filter_dict[column] = NCV_filter if column in ['include']: ncv_filters.append(NCV.__dict__[column] == NCV_filter) else: ncv_filters.append(NCV.__dict__[column].contains(str(NCV_filter))) for column in sample_columns: NCV_filter = request.args.get(column) if NCV_filter: filter_dict[column] = NCV_filter sample_filters.append(Sample.__dict__['status_'+ column] == NCV_filter) # filtering NCV_db = NCV.query if ncv_filters: NCV_db = NCV_db.filter(and_(* ncv_filters)) if sample_filters: NCV_db = NCV_db.join(Sample).filter(and_(* sample_filters)) if batch_filter: NCV_db = NCV_db.join(Batch).filter(and_(* batch_filter)) if not (ncv_filters or sample_filters or batch_filter): # show first 50 NCV_db = NCV.query.all()[0:50] else: NCV_db = NCV_db.all() # get clasifications DC = DataClasifyer(NCV_db) DC.handle_NCV() return render_template('samples.html', abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified','Failed'], chrom_abnorm = sample_columns, nr_included_samps = NCV.query.filter(NCV.include).count(), NCV_db = NCV_db, NCV_sex = DC.NCV_sex, NCV_warnings = DC.NCV_classified, filter_dict = filter_dict )
def sample_tris_plot( sample_id): L = Layout() sample = Sample.query.filter_by(sample_ID = sample_id).first() NCV_dat = NCV.query.filter_by(sample_ID = sample_id) batch_id = sample.batch_id batch = Batch.query.filter_by(batch_id = batch_id).first() batch_stat = BatchStat.query.filter(BatchStat.batch_id == batch_id).first() DC = DataClasifyer(NCV_dat) DC.handle_NCV() # Getting and formating sample and NCV data for the control samples in the plot TA = TrisAbnormality(batch_id, NCV_dat) control_normal, control_abnormal_13 = BDF.control_NCV13() case_data13 = TA.make_case_data(control_normal, '13') control_normal, control_abnormal_18 = BDF.control_NCV18() case_data18 = TA.make_case_data(control_normal,'18') control_normal, control_abnormal_21 = BDF.control_NCV21() case_data21 = TA.make_case_data(control_normal,'21') TA.make_tris_abn_sample_page(control_abnormal_13 + control_abnormal_18 + control_abnormal_21) case_data = {'NCV_13':case_data13, 'NCV_18':case_data18, 'NCV_21':case_data21} return render_template('sample_page/sample_tris_plot.html', ## Header & Info Box NCV_dat = NCV_dat.first(), sample = sample, sample_id = sample_id, batch_id = batch_id, batch_name = batch.batch_name, batch = batch, NCV_sex = DC.NCV_sex[sample_id], NCV_warn = DC.NCV_classified[sample_id], ## Plots batch_stat = batch_stat, tris_abn = TA.tris_abn, case_size = L.case_size, abn_size = L.abn_size, abn_symbol = L.abn_symbol, abn_line = L.abn_line, abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified','False Negative'], ncv_abn_colors = L.ncv_abn_colors, case_data = case_data, tris_thresholds = DC.tris_thresholds)
def batch(): NCV_db = NCV.query DH = DataHandler() sample_db = Sample.query DC = DataClasifyer() DC.handle_NCV(NCV_db) DC.get_QC_warnings(sample_db) return render_template('start_page.html', batches = Batch.query, nr_included_samps = DH.nr_included_samps, samples = Sample.query, NCV_db = NCV.query, NCV_sex = DC.NCV_sex, NCV_warnings = DC.NCV_classified)
def samples(): # import ipdb; ipdb.set_trace() NCV_db = NCV.query sample_db = Sample.query DC = DataClasifyer() DC.handle_NCV(NCV_db) DC.get_manually_classified(sample_db) return render_template('samples.html', nr_included_samps = NCV.query.filter(NCV.include).count(), NCV_db = sample_db, NCV_sex = DC.NCV_sex, sample_names = DC.sample_names, NCV_man_class = DC.man_class, NCV_warnings = DC.NCV_classified, NCV_comment = DC.NCV_comment, batch_info = DC.batch )
def sample(batch_id): NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer() DC.handle_NCV(NCV_db) DC.get_QC_warnings(sample_db) DC.get_manually_classified(sample_db) PP = PlottPage(batch_id) PP.make_NCV_stat() PP.make_chrom_abn() PP.make_cov_plot_data() return render_template('batch_page.html', NCV_samples = NCV.query.filter(NCV.batch_id == batch_id), batch_name = batch.batch_name, man_class = DC.man_class, NCV_stat = PP.NCV_stat, NCV_sex = DC.NCV_sex, seq_date = batch.date, nr_validation_samps = PP.nr_validation_samps, samp_range = range(len(PP.NCV_stat['NCV_X']['NCV_cases'])), tris_chrom_abn = PP.tris_chrom_abn, sex_chrom_abn = PP.sex_chrom_abn, abn_status_list = ['Verified','False Positive', 'Probable', 'Suspected'], many_colors = PP.many_colors, sex_abn_colors = PP.sex_abn_colors, sex_tresholds = DC.sex_tresholds, tris_thresholds = DC.tris_thresholds, seq_warnings = DC.QC_warnings, warnings = DC.NCV_classified, NCV_rounded = DC.NCV_data, samp_cov_db = PP.coverage_plot, sample_ids = ','.join(sample.sample_ID for sample in NCV_db))
def sample_xy_plot( sample_id): L = Layout() sample = Sample.query.filter_by(sample_ID = sample_id).first() NCV_dat = NCV.query.filter_by(sample_ID = sample_id) batch_id = sample.batch_id batch = Batch.query.filter_by(batch_id = batch_id).first() DC = DataClasifyer(NCV_dat) DC.handle_NCV() DC.make_sex_tresholds(BDF.NCV_passed_X) chrom_abnorm = ['T13','T18', 'T21', 'X0', 'XXX','XXY','XYY'] db_entries = {c:sample.__dict__['status_'+c].replace('\r\n', '').strip() for c in chrom_abnorm } db_entries_change = {c:sample.__dict__['status_change_'+c] for c in chrom_abnorm} # Getting and formating sample and NCV data for the control samples in the plot control_normal_X, control_normal_Y, control_normal_XY_names = BDF.control_NCVXY() SA = SexAbnormality(batch_id, NCV_dat) SA.make_case_data('NCV_X', control_normal_X) SA.make_case_data('NCV_Y', control_normal_Y) SA.make_sex_chrom_abn() return render_template('sample_page/sample_xy_plot.html', ## Header & Info Box NCV_dat = NCV_dat.first(), sample_name = sample.sample_name, sample = sample, sample_id = sample_id, batch_id = batch_id, batch_name = batch.batch_name, batch_date = batch.date, NCV_sex = DC.NCV_sex[sample_id], NCV_warn = DC.NCV_classified[sample_id], ## Plots sex_chrom_abn = SA.sex_chrom_abn, case_size = L.case_size, abn_size = L.abn_size, abn_symbol = L.abn_symbol, abn_line = L.abn_line, abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified'], ncv_abn_colors = L.ncv_abn_colors, case_data = SA.case_data, sex_tresholds = DC.sex_tresholds)
def sample_page( sample_id): sample = Sample.query.filter_by(sample_ID = sample_id).first() batch_id = sample.batch_id batch = Batch.query.filter_by(batch_id = batch_id).first() NCV_db = NCV.query.filter(NCV.batch_id == batch_id) DC = DataClasifyer() DC.handle_NCV(NCV_db) NCV_dat = NCV.query.filter_by(sample_ID = sample_id).first() chrom_abnorm = ['T13','T18', 'T21', 'X0', 'XXX','XXY','XYY'] db_entries = {c:sample.__dict__['status_'+c].replace('\r\n', '').strip() for c in chrom_abnorm } db_entries_change = {c:sample.__dict__['status_change_'+c] for c in chrom_abnorm} db_entries_comments = {c : sample.__dict__['comment_'+c] for c in chrom_abnorm} PP = PlottPage(batch_id) PP.make_NCV_stat() PP.make_chrom_abn() sample_state_dict = PP.sample_state_dict for state in sample_state_dict: sample_state_dict[state]['T_13'] = Sample.query.filter_by(status_T13 = state) sample_state_dict[state]['T_18'] = Sample.query.filter_by(status_T18 = state) sample_state_dict[state]['T_21'] = Sample.query.filter_by(status_T21 = state) return render_template('sample_page.html', NCV_dat = NCV_dat, tris_abn = PP.tris_abn, sex_chrom_abn = PP.sex_chrom_abn, abn_status_list = ['Verified','False Positive', 'Probable', 'Suspected'], sex_abn_colors = PP.sex_abn_colors, sample = sample, NCV_db = NCV.query.filter_by(sample_ID = sample_id).first(), batch_id = batch_id, batch_name = batch.batch_name, batch = batch, nr_validation_samps = PP.nr_validation_samps, sample_id = sample_id, chrom_abnorm = chrom_abnorm, db_entries = db_entries, db_entries_comments = db_entries_comments, db_entries_change = db_entries_change, NCV_stat = PP.NCV_stat, NCV_131821 = ['NCV_13', 'NCV_18', 'NCV_21'], state_dict = sample_state_dict, sex_tresholds = DC.sex_tresholds, tris_thresholds = DC.tris_thresholds, NCV_sex = DC.NCV_sex[sample_id], NCV_warn = DC.NCV_classified[sample_id])
def sample_page( sample_id): sample = Sample.query.filter_by(sample_ID = sample_id).first() batch_id = sample.batch_id batch = Batch.query.filter_by(batch_id = batch_id).first() NCV_db = NCV.query.filter(NCV.batch_id == batch_id) DC = DataClasifyer(NCV_db) DC.handle_NCV() DC.make_sex_tresholds(BDF.NCV_passed_X) NCV_dat = NCV.query.filter_by(sample_ID = sample_id).first() chrom_abnorm = ['T13','T18', 'T21', 'X0', 'XXX','XXY','XYY'] db_entries = {c:sample.__dict__['status_'+c].replace('\r\n', '').strip() for c in chrom_abnorm } db_entries_change = {c:sample.__dict__['status_change_'+c] for c in chrom_abnorm} PP = PlottPage(batch_id, BDF) PP.make_NCV_stat() PP.make_chrom_abn() return render_template('sample_page.html', ## Header & Info Box NCV_dat = NCV_dat, sample = sample, batch_id = batch_id, batch_name = batch.batch_name, batch = batch, NCV_sex = DC.NCV_sex[sample_id], NCV_warn = DC.NCV_classified[sample_id], ## Comment NCV_db = NCV.query.filter_by(sample_ID = sample_id).first(), ## NCV Table sample_id = sample_id, chrom_abnorm = chrom_abnorm, db_entries = db_entries, db_entries_change = db_entries_change, ## Plots tris_abn = PP.tris_abn, sex_chrom_abn = PP.sex_chrom_abn, case_size = PP.case_size, abn_size = PP.abn_size, abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified'], ncv_abn_colors = PP.ncv_abn_colors, NCV_stat = PP.NCV_stat, NCV_131821 = ['NCV_13', 'NCV_18', 'NCV_21'], sex_tresholds = DC.sex_tresholds, tris_thresholds = DC.tris_thresholds, tris_chrom_abn = PP.tris_chrom_abn)
def sample(batch_id): NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer(NCV_db) DC.handle_NCV() DC.make_sex_tresholds(BDF.NCV_passed_X) DC.get_QC_warnings(sample_db) DC.get_manually_classified(sample_db) PP = PlottPage(batch_id, BDF) PP.make_NCV_stat() PP.make_chrom_abn() PP.make_cov_plot_data() return render_template('batch_page.html', ## Header batch_name = batch.batch_name, seq_date = batch.date, ## Warnings Table seq_warnings = DC.QC_warnings, ## NCV Table NCV_samples = NCV.query.filter(NCV.batch_id == batch_id), man_class = DC.man_class_merged, NCV_sex = DC.NCV_sex, warnings = DC.NCV_classified, NCV_rounded = DC.NCV_data, ## Plotts NCV_stat = PP.NCV_stat, case_size = PP.case_size, abn_size = PP.abn_size, samp_range = range(len(PP.NCV_stat['NCV_X']['NCV_cases'])), tris_chrom_abn = PP.tris_chrom_abn, sex_chrom_abn = PP.sex_chrom_abn, abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified'], cov_colors = PP.cov_colors, many_colors = PP.many_colors, ncv_abn_colors = PP.ncv_abn_colors, sex_tresholds = DC.sex_tresholds, tris_thresholds = DC.tris_thresholds, ## Coverage bool_warns = filter(None, DC.NCV_classified.values()), samp_cov_db = PP.coverage_plot, ## Buttons batch_id = batch_id, sample_ids = ','.join(sample.sample_ID for sample in NCV_db))
def batch(): NCV_db = NCV.query DH = DataHandler() sample_db = Sample.query DC = DataClasifyer() DC.handle_NCV(NCV_db) DC.get_QC_warnings(sample_db) return render_template('start_page.html', batches=Batch.query, nr_included_samps=DH.nr_included_samps, samples=Sample.query, NCV_db=NCV.query, NCV_sex=DC.NCV_sex, NCV_warnings=DC.NCV_classified)
def NCVXY_plot(batch_id): L = Layout(batch_id) # Getting and formating sample and NCV data for the samples in the batch NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer(NCV_db) DC.handle_NCV() DC.make_sex_tresholds(BDF.NCV_passed_X) DC.get_QC_warnings(sample_db) # Getting and formating sample and NCV data for the control samples in the plot control_normal_X, control_normal_Y, control_normal_XY_names = BDF.control_NCVXY() SA = SexAbnormality(batch_id, NCV_db) SA.make_case_data('NCV_X', control_normal_X) SA.make_case_data('NCV_Y', control_normal_Y) SA.make_sex_chrom_abn() return render_template('batch_page/tab_NCVXY.html', ## Header batch_name = batch.batch_name, seq_date = batch.date, ## Warnings Table seq_warnings = DC.QC_warnings, ## Plotts NCV_pass_names = control_normal_XY_names, case_data = SA.case_data, case_size = L.case_size, case_line = L.case_line, abn_size = L.abn_size, abn_line = L.abn_line, abn_symbol = L.abn_symbol, samp_range = range(len(SA.case_data['NCV_X']['samples'])), sex_chrom_abn = SA.sex_chrom_abn, abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified','False Negative'], many_colors = L.many_colors_dict, sex_tresholds = DC.sex_tresholds, ncv_abn_colors = L.ncv_abn_colors, ## Buttons batch_id = batch_id, sample_ids = ','.join(sample.sample_ID for sample in NCV_db), sample_list = SA.sample_list)
def sample(batch_id): NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer() DC.handle_NCV(NCV_db) DC.get_QC_warnings(sample_db) DC.get_manually_classified(sample_db) PP = PlottPage(batch_id) PP.make_NCV_stat() PP.make_chrom_abn() PP.make_cov_plot_data() return render_template( 'batch_page.html', NCV_samples=NCV.query.filter(NCV.batch_id == batch_id), batch_name=batch.batch_name, man_class=DC.man_class, NCV_stat=PP.NCV_stat, NCV_sex=DC.NCV_sex, seq_date=batch.date, nr_validation_samps=PP.nr_validation_samps, samp_range=range(len(PP.NCV_stat['NCV_X']['NCV_cases'])), tris_chrom_abn=PP.tris_chrom_abn, sex_chrom_abn=PP.sex_chrom_abn, abn_status_list=[ 'Verified', 'False Positive', 'Probable', 'Suspected' ], many_colors=PP.many_colors, sex_abn_colors=PP.sex_abn_colors, sex_tresholds=DC.sex_tresholds, tris_thresholds=DC.tris_thresholds, seq_warnings=DC.QC_warnings, warnings=DC.NCV_classified, NCV_rounded=DC.NCV_data, samp_cov_db=PP.coverage_plot, sample_ids=','.join(sample.sample_ID for sample in NCV_db))
def sample(batch_id): NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer(NCV_db) DC.handle_NCV() DC.get_QC_warnings(sample_db) DC.get_manually_classified(sample_db) return render_template('batch_page/batch_page.html', current_user = current_user, ## Header batch_name = batch.batch_name, seq_date = batch.date, ## Warnings Table seq_warnings = DC.QC_warnings, ## NCV Table NCV_samples = NCV.query.filter(NCV.batch_id == batch_id), man_class = DC.man_class_merged, NCV_sex = DC.NCV_sex, warnings = DC.NCV_classified, batch_table_data = DC.NCV_data, ## Buttons batch_id = batch_id, sample_ids = ','.join(sample.sample_ID for sample in NCV_db))
def report(batch_id, coverage): L = Layout(batch_id) NCV_db = NCV.query.filter(NCV.batch_id == batch_id) sample_db = Sample.query.filter(Sample.batch_id == batch_id) batch = Batch.query.filter(Batch.batch_id == batch_id).first() DC = DataClasifyer(NCV_db) DC.handle_NCV() DC.make_sex_tresholds(BDF.NCV_passed_X) DC.get_QC_warnings(sample_db) DC.get_manually_classified(sample_db) CP = CoveragePlot(batch_id) CP.make_cov_plot_data() control_normal_X, control_normal_Y, control_normal_XY_names = BDF.control_NCVXY() SA = SexAbnormality(batch_id, NCV_db) SA.make_case_data('NCV_X', control_normal_X) SA.make_case_data('NCV_Y', control_normal_Y) SA.make_sex_chrom_abn() TA = TrisAbnormality(batch_id, NCV_db) control_normal, control_abnormal = BDF.control_NCV13() case_data13 = TA.make_case_data(control_normal, '13') tris_chrom_abn13 = TA.make_tris_chrom_abn(control_abnormal, '13') control_normal, control_abnormal = BDF.control_NCV18() case_data18 = TA.make_case_data(control_normal,'18') tris_chrom_abn18 = TA.make_tris_chrom_abn(control_abnormal, '18') control_normal, control_abnormal = BDF.control_NCV21() case_data21 = TA.make_case_data(control_normal, '21') tris_chrom_abn21 = TA.make_tris_chrom_abn(control_abnormal, '21') tris_case_data = {'NCV_13':case_data13, 'NCV_18':case_data18, 'NCV_21':case_data21} tris_chrom_abn = {'13':tris_chrom_abn13, '18':tris_chrom_abn18, '21':tris_chrom_abn21} CC = CovXCovY(batch_id) CC.format_case_dict() CC.format_contol_dict() CC.format_pos_contol() ST = Statistics() ST.get_20_latest() return render_template('batch_page/report_page.html', ## Header batch_name = batch.batch_name, ## Warnings Table seq_warnings = DC.QC_warnings, ## NCV Table NCV_samples = NCV.query.filter(NCV.batch_id == batch_id), man_class = DC.man_class_merged, NCV_sex = DC.NCV_sex, warnings = DC.NCV_classified, batch_table_data = DC.NCV_data, ## Plotts batch_names = ST.batch_names, thresholds = ST.thresholds, batch_ids = ST.batch_ids, case_size = L.case_size, abn_size = L.abn_size, abn_symbol = L.abn_symbol, case_line = L.case_line, abn_line = L.abn_line, cov_colors = L.cov_colors, many_colors = L.many_colors_dict, samp_range = range(len(SA.case_data['NCV_X']['samples'])), tris_chrom_abn = tris_chrom_abn, tris_case_data = tris_case_data, case_data = SA.case_data, ## i xy-plot sex_chrom_abn = SA.sex_chrom_abn, abn_status_list = ['Other','False Positive','Suspected', 'Probable', 'Verified'], ncv_abn_colors = L.ncv_abn_colors, sex_tresholds = DC.sex_tresholds, tris_thresholds = DC.tris_thresholds, NCV_pass_names = control_normal_XY_names, ## Coverage coverage = coverage, samp_cov_db = CP.coverage_plot, nr_contol_samples = CC.nr_contol_samples, cases = CC.samples, control = CC.control, pos_contol = CC.pos_contol, sample_list = SA.sample_list)