Skip to content

Commit

Permalink
fixup! Format Python code with psf/black pull_request
Browse files Browse the repository at this point in the history
  • Loading branch information
PMBio authored and PMBio committed May 13, 2024
1 parent b129771 commit 06d771f
Show file tree
Hide file tree
Showing 2 changed files with 290 additions and 239 deletions.
20 changes: 13 additions & 7 deletions deeprvat/annotations/annotations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'

os.environ["TF_CPP_MIN_LOG_LEVEL"] = "1"
import pickle
import random
import sys
Expand Down Expand Up @@ -1470,7 +1471,7 @@ def add_ids(annotation_file: str, variant_file: str, njobs: int, out_file: str):
@click.argument("annotation_file", type=click.Path(exists=True))
@click.argument("variant_file", type=click.Path(exists=True))
@click.argument("out_file", type=click.Path())
def add_ids_dask(annotation_file: str, variant_file: str, out_file: str):
def add_ids_dask(annotation_file: str, variant_file: str, out_file: str):
"""
Add identifiers from a variant file to an annotation file using Dask and save the result.
Expand Down Expand Up @@ -1737,15 +1738,20 @@ def process_vep(
vcf_file, names=["chrom", "pos", "#Uploaded_variation", "ref", "alt"]
)
if "#Uploaded_variation" in vep_file.columns:
vep_file = vep_file.merge(vcf_df, on="#Uploaded_variation", how = 'left')
if vep_file.chrom.isna().sum()>0:
vep_file.loc[vep_file.chrom.isna(),['chrom','pos','ref','alt']]=vep_file[vep_file['chrom'].isna()]['#Uploaded_variation'].str.replace("_", ":").str.replace("/", ":").str.split(':', expand=True).values
vep_file = vep_file.merge(vcf_df, on="#Uploaded_variation", how="left")
if vep_file.chrom.isna().sum() > 0:
vep_file.loc[vep_file.chrom.isna(), ["chrom", "pos", "ref", "alt"]] = (
vep_file[vep_file["chrom"].isna()]["#Uploaded_variation"]
.str.replace("_", ":")
.str.replace("/", ":")
.str.split(":", expand=True)
.values
)
assert vep_file.chrom.isna().sum() == 0
assert vep_file.pos.isna().sum() == 0
assert vep_file.ref.isna().sum() == 0
assert vep_file.alt.isna().sum() == 0



if "pos" in vep_file.columns:
vep_file["pos"] = vep_file["pos"].astype(int)

Expand Down
Loading

0 comments on commit 06d771f

Please sign in to comment.