Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
444thLiao committed Apr 23, 2018
1 parent 5f7e31b commit c7ad3f3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions aft_pipelines_analysis/aft_pipelines_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
## 18/03/23
## absoulte path

script_path = __file__
script_path = os.path.abspath(__file__)
dir_script = os.path.dirname(script_path)

if len(sys.argv) == 3 and '/' in sys.argv[1]:
Expand Down Expand Up @@ -230,8 +230,9 @@ def draw_coverage_depths():
else:
normal_name = each_pair + NORMAL_SIG
tumor_name = each_pair + TUMOR_SIG
cmdline = 'python %s/extracted_pos_from_vcf.py %s %s %s %s' % (
cmdline = 'python %s/extracted_pos_from_vcf.py %s %s %s %s %s' % (
dir_script,
server_setting_path,
bed_file,
'%s/%s.mt2.vcf' % (vcf_path, each_pair),
'%s/%s.mt2.vcf' % (vcf_path, tumor_name),
Expand Down
19 changes: 11 additions & 8 deletions aft_pipelines_analysis/extracted_pos_from_vcf.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import os

bcftools_path = '/home/liaoth/tools/bcftools-1.3.1/bcftools'

def prepare_vcf(vcf_path):
if not vcf_path.endswith('.gz'):
os.system('`which bgzip` %s' % vcf_path)
vcf_path += '.gz'
print vcf_path
os.system('/home/liaoth/tools/bcftools-1.3.1/bcftools index %s' % vcf_path)
os.system('%s index %s' % (bcftools_path,vcf_path))
else:
if not os.path.isfile(vcf_path + '.csi'):
os.system('/home/liaoth/tools/bcftools-1.3.1/bcftools index %s' % vcf_path)
os.system('%s index %s' % (bcftools_path,vcf_path))


def merge_two_vcf(pair_vcf, bed, single_vcf, output_vcf):
Expand All @@ -19,7 +20,7 @@ def merge_two_vcf(pair_vcf, bed, single_vcf, output_vcf):
single_sample_name = os.popen("zgrep '^#C' %s | cut -f 10-" % single_vcf).read().replace('\n', '').replace('\t',
',')

formatted_line = '''/home/liaoth/tools/bcftools-1.3.1/bcftools view {vcf} -R {bed} -s ^{SM} --force-samples | vcf-sort > {output}'''
formatted_line = '''%s view {vcf} -R {bed} -s ^{SM} --force-samples | vcf-sort > {output}''' % bcftools_path
cmdline1 = formatted_line.format(vcf=pair_vcf.replace('.gz', '') + '.gz', bed=bed, output=output_vcf + '1',
SM=pair_sample_name)
cmdline2 = formatted_line.format(vcf=single_vcf.replace('.gz', '') + '.gz', bed=bed, output=output_vcf + '2',
Expand All @@ -31,7 +32,8 @@ def merge_two_vcf(pair_vcf, bed, single_vcf, output_vcf):
prepare_vcf(output_vcf + '1');
prepare_vcf(output_vcf + '2');

formatted_line2 = """/home/liaoth/tools/bcftools-1.3.1/bcftools concat {o1} {o2} -a -d all > {output}""".format(
formatted_line2 = """{bcftools} concat {o1} {o2} -a -d all > {output}""".format(
bcftools = bcftools_path,
o1=output_vcf + '1.gz',
o2=output_vcf + '2.gz',
output=output_vcf)
Expand All @@ -43,10 +45,11 @@ def merge_two_vcf(pair_vcf, bed, single_vcf, output_vcf):
if __name__ == '__main__':
import sys

bed_f = sys.argv[1]
pairedvcf = sys.argv[2]
single_vcf = sys.argv[3]
output_vcf = sys.argv[4]
setting_f = sys.argv[1]
bed_f = sys.argv[2]
pairedvcf = sys.argv[3]
single_vcf = sys.argv[4]
output_vcf = sys.argv[5]
# merge_two_vcf('/home/liaoth/project/180104_XK/gpz_server/vcf_storge/XK-25.mt2.vcf',
# '/home/liaoth/project/180104_XK/gpz_server/analysis_result/filtered_somatic/XK-25_filtered_somatic.bed'
# , '/home/liaoth/project/180104_XK/gpz_server/vcf_storge/XK-25T.mt2.vcf',
Expand Down
2 changes: 1 addition & 1 deletion aft_pipelines_analysis/filter_pipelines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function
from genes_list import snp_138_common_init,formatt_col
from filters import *
import pandas,time
import argparse
import os, sys, glob
Expand Down Expand Up @@ -150,6 +149,7 @@ def filter_pipelines2(normal_germline,normal_somatic, tumor_somatic,pair_somatic
import_path = os.path.dirname(setting_file)
sys.path.insert(0, import_path)
from setting import *
from filters import *
############################################################
samples_ids = [os.path.basename(i).split('.mt2.merged.')[0] for i in glob.glob(os.path.join(csv_output_dir, 'somatic', '*.csv'))]
pair_name = [i for i in samples_ids if NORMAL_SIG not in i and TUMOR_SIG not in i]
Expand Down
2 changes: 1 addition & 1 deletion aft_pipelines_analysis/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pandas as pd
import tqdm

BED_INFO = pd.read_csv('/home/liaoth/data2/project/XK_WES/Sureselect_V6_COSMIC_formal.bed', sep='\t', header=None,
BED_INFO = pd.read_csv(local_bed_file, sep='\t', header=None,
index_col=None)
range_list = []
for idx in tqdm.tqdm(range(BED_INFO.shape[0])):
Expand Down
1 change: 1 addition & 0 deletions setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
local_vt_pro = '/home/liaoth/tools/vt/vt'
pcgr_pro = '/home/liaoth/data2/pcgr-0.5.3'
local_hg19_ref_db = '/home/liaoth/data2/hg19/ucsc.hg19.fasta'
local_bed_file = '/home/liaoth/data2/project/XK_WES/Sureselect_V6_COSMIC_formal.bed'
#####Paired format.
PE1_fmt = '{input}_R1'
PE2_fmt = '{input}_R2'
Expand Down

0 comments on commit c7ad3f3

Please sign in to comment.