def _format_variant(self, gemini_variant, individual_objs, index=0, add_all_info=False): """Make a puzzle variant from a gemini variant Args: gemini_variant (GeminiQueryRow): The gemini variant individual_objs (list(dict)): A list of Individuals index(int): The index of the variant Returns: variant (dict): A Variant object """ chrom = gemini_variant['chrom'] if chrom.startswith('chr') or chrom.startswith('CHR'): chrom = chrom[3:] variant_dict = { 'CHROM':chrom, 'POS':str(gemini_variant['start']), 'ID':gemini_variant['rs_ids'], 'REF':gemini_variant['ref'], 'ALT':gemini_variant['alt'], 'QUAL':gemini_variant['qual'], 'FILTER':gemini_variant['filter'] } variant = Variant(**variant_dict) # Use the gemini id for fast search variant.update_variant_id(gemini_variant['variant_id']) logger.debug("Creating a variant object of variant {0}".format( variant.variant_id)) variant['index'] = index # Add the most severe consequence self._add_most_severe_consequence(variant, gemini_variant) #Add the impact severity self._add_impact_severity(variant, gemini_variant) ### POSITON ANNOATTIONS ### variant.start = int(gemini_variant['start']) variant.stop = int(gemini_variant['end']) #Add the sv specific coordinates if self.variant_type == 'sv': variant.sv_type = gemini_variant['sub_type'] variant.stop = int(gemini_variant['end']) self._add_sv_coordinates(variant) else: ### Consequence and region annotations #Add the transcript information self._add_transcripts(variant, gemini_variant) self._add_thousand_g(variant, gemini_variant) self._add_exac(variant, gemini_variant) self._add_gmaf(variant, gemini_variant) #### Check the impact annotations #### if gemini_variant['cadd_scaled']: variant.cadd_score = gemini_variant['cadd_scaled'] # We use the prediction in text polyphen = gemini_variant['polyphen_pred'] if polyphen: variant.add_severity('Polyphen', polyphen) # We use the prediction in text sift = gemini_variant['sift_pred'] if sift: variant.add_severity('SIFT', sift) #Add the genes based on the hgnc symbols self._add_hgnc_symbols(variant) if self.variant_type == 'snv': self._add_genes(variant) self._add_consequences(variant) ### GENOTYPE ANNOATTIONS ### #Get the genotype info if add_all_info: self._add_genotypes(variant, gemini_variant, individual_objs) if self.variant_type == 'sv': self._add_genes(variant) return variant
def _format_variant(self, case_id, gemini_variant, individual_objs, index=0, add_all_info=False): """Make a puzzle variant from a gemini variant Args: case_id (str): related case id gemini_variant (GeminiQueryRow): The gemini variant individual_objs (list(dict)): A list of Individuals index(int): The index of the variant Returns: variant (dict): A Variant object """ chrom = gemini_variant['chrom'] if chrom.startswith('chr') or chrom.startswith('CHR'): chrom = chrom[3:] variant_dict = { 'CHROM': chrom, 'POS': str(gemini_variant['start']), 'ID': gemini_variant['rs_ids'], 'REF': gemini_variant['ref'], 'ALT': gemini_variant['alt'], 'QUAL': gemini_variant['qual'], 'FILTER': gemini_variant['filter'] } variant = Variant(**variant_dict) # Use the gemini id for fast search variant.update_variant_id(gemini_variant['variant_id']) logger.debug("Creating a variant object of variant {0}".format( variant.variant_id)) variant['index'] = index # Add the most severe consequence self._add_most_severe_consequence(variant, gemini_variant) #Add the impact severity self._add_impact_severity(variant, gemini_variant) ### POSITON ANNOATTIONS ### variant.start = int(gemini_variant['start']) variant.stop = int(gemini_variant['end']) #Add the sv specific coordinates if self.variant_type == 'sv': variant.sv_type = gemini_variant['sub_type'] variant.stop = int(gemini_variant['end']) self._add_sv_coordinates(variant) else: ### Consequence and region annotations #Add the transcript information self._add_transcripts(variant, gemini_variant) self._add_thousand_g(variant, gemini_variant) self._add_exac(variant, gemini_variant) self._add_gmaf(variant, gemini_variant) #### Check the impact annotations #### if gemini_variant['cadd_scaled']: variant.cadd_score = gemini_variant['cadd_scaled'] # We use the prediction in text polyphen = gemini_variant['polyphen_pred'] if polyphen: variant.add_severity('Polyphen', polyphen) # We use the prediction in text sift = gemini_variant['sift_pred'] if sift: variant.add_severity('SIFT', sift) #Add the genes based on the hgnc symbols self._add_hgnc_symbols(variant) if self.variant_type == 'snv': self._add_genes(variant) self._add_consequences(variant) ### GENOTYPE ANNOATTIONS ### #Get the genotype info if add_all_info: self._add_genotypes(variant, gemini_variant, case_id, individual_objs) if self.variant_type == 'sv': self._add_genes(variant) return variant