def command_info(cls, id=None, running=None, failed=None): cmds = {} if id is not None: try: id = int(id) return jsonreadify(cls.launched_commands[id]) except KeyError: raise CommandError("No such command with ID %s" % repr(id)) except ValueError: raise CommandError("Invalid ID %s" % repr(id)) if running is not None: is_done = not to_boolean(running) else: is_done = None if failed is not None: failed = to_boolean(failed) for _id, cmd in cls.launched_commands.items(): if is_done is not None: # running or done commands (not both) if cmd.get("is_done") == is_done: # done + failed (a failed command is always done btw) if failed is not None and cmd.get("is_done") == True: if cmd.get("failed") == failed: cmds[_id] = jsonreadify(cmd) else: # don't care if failed or not cmds[_id] = jsonreadify(cmd) else: # If asked is_done=true, it means command _id has is_done=false # if we get there. So the command is sill running, so we don't # know if it failed or not, so no need to check failed there, # it's been handled above. # If asksed is_done=false, we don't need to check failed, # same logic applies continue else: # either running or done commands (both) if failed is not None and cmd.get("is_done") == True: if cmd.get("failed") == failed: cmds[_id] = jsonreadify(cmd) else: # don't care if failed or not cmds[_id] = jsonreadify(cmd) return cmds
def _map_line_to_json(df): chrom = df['chromosome'] if chrom == 'M': chrom = 'MT' ref = df["reference_allele"] alt = df["tumor_seq_allele1"] if alt == '-': HGVS = get_hgvs_from_vcf(chrom, int(df['start_position']) - 1, 'N' + ref, 'N', mutant_type=False) elif ref == '-': HGVS = get_hgvs_from_vcf(chrom, int(df['start_position']) - 1, 'N', 'N' + alt, mutant_type=False) else: HGVS = get_hgvs_from_vcf(chrom, int(df['start_position']), ref, alt, mutant_type=False) ccle_depmap = { 'gene': { 'id': df['entrez_gene_id'], 'symbol': df['hugo_symbol'] }, 'chrom': chrom, 'hg19': { 'start': df['start_position'], 'end': df['end_position'] }, 'strand': df['strand'], 'class': df['variant_classification'], 'vartype': df['variant_type'], 'ref': df['reference_allele'], 'tumor_seq_allele1': df['tumor_seq_allele1'], 'dbsnp': { 'rsid': df['dbsnp_rs'], 'val_status': df['dbsnp_val_status'] }, 'genome_change': df['genome_change'], 'annotation_transcript': df['annotation_transcript'], 'tumor_sample_barcode': df['tumor_sample_barcode'], 'cdna_change': df['cdna_change'], 'codon_change': df['codon_change'], 'protein_change': df['protein_change'], 'isdeleterious': to_boolean(df['isdeleterious'], true_str=[ 'TRUE', ], false_str=[ 'FALSE', ]), 'istcgahotspot': to_boolean(df['istcgahotspot'], true_str=[ 'TRUE', ], false_str=[ 'FALSE', ]), 'tcgahscnt': df['tcgahscnt'], 'iscosmichotspot': to_boolean(df['iscosmichotspot'], true_str=[ 'TRUE', ], false_str=[ 'FALSE', ]), 'cosmichscnt': df['cosmichscnt'], 'exac_af': df['exac_af'], 'wes_ac': df['wes_ac'], 'sanger': { 'wes_ac': df['sangerwes_ac'], 'recalibwes_ac': df['sangerrecalibwes_ac'] }, 'rnaseq_ac': df['rnaseq_ac'], 'hc_ac': df['hc_ac'], 'rd_ac': df['rd_ac'], 'wgs_ac': df['wgs_ac'], 'broad_id': df['broad_id'] } ccle_depmap = dict_sweep(ccle_depmap) # load as json data one_snp_json = {"_id": HGVS, "ccle": ccle_depmap} one_snp_json = value_convert_to_number(one_snp_json) one_snp_json['ccle']['chrom'] = str(one_snp_json['ccle']['chrom']) return one_snp_json
def get(self,name=None): debug = to_boolean(self.get_query_argument("debug",False)) if name: self.write(self.get_source(name,debug)) else: self.write(self.get_sources(debug))