Skip to content

Commit

Permalink
Torrent Suite Software 5.2.2-sp1 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-pan-tfs committed Apr 14, 2017
1 parent 4c9e90b commit 628712b
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Analysis/VariantCaller/tvcutils/prepare_hotspots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,24 +886,23 @@ int PrepareHotspots(int argc, const char *argv[])

map<string,map<string,string> > unique_alts_and_tags;
set<string> unique_tags;
set<string> unique_alt_alleles;

for (deque<Allele>::iterator I = A; I != B; ++I) {
if (I->filtered)
continue;
unique_alts_and_tags[I->alt].insert(I->custom_tags.begin(), I->custom_tags.end());
for (map<string,string>::iterator S = I->custom_tags.begin(); S != I->custom_tags.end(); ++S)
unique_tags.insert(S->first);
/*
if (unique_alt_alleles.count(I->alt) > 0)
continue;
unique_alt_alleles.insert(I->alt);
if (comma)
fprintf(output_vcf, ",");
comma = true;
fprintf(output_vcf, "%s", I->alt.c_str());
*/
}

/*
for (deque<Allele>::iterator I = A; I != B; ++I) {
if (I->filtered)
continue;
Expand All @@ -914,6 +913,7 @@ int PrepareHotspots(int argc, const char *argv[])
if (Q == unique_alts_and_tags.end()) {fprintf(output_vcf, "."); continue;}
fprintf(output_vcf, "%s", Q->first.c_str());
}
*/

fprintf(output_vcf, "\t.\t.\tOID=");
comma = false;
Expand Down
2 changes: 1 addition & 1 deletion Analysis/version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version for target of current development cycle
MAJOR=5
MINOR=2
RELEASE=25
RELEASE=26
8 changes: 7 additions & 1 deletion plugin/variantCaller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ add_custom_target(parameter_sets ALL
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/pluginMedia/parameter_sets/"
COMMENT "Combining individual parameter sets into a single parameter_sets.json")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/parameter_sets.json" DESTINATION "${CPACK_PACKAGE_INSTALL_DIRECTORY}/variantCaller/pluginMedia/parameter_sets")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/parameter_sets.json" DESTINATION "${CPACK_PACKAGE_INSTALL_DIRECTORY}/variantCaller/pluginMedia/parameter_sets")

# TS-13996
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/../../Analysis")
message(STATUS "Adding tvcutils from Analysis build")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/../../Analysis/tvcutils" DESTINATION "${CPACK_PACKAGE_INSTALL_DIRECTORY}/variantCaller/bin/")
endif()
2 changes: 1 addition & 1 deletion plugin/variantCaller/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ulimit -s 8192
#$ -l mem_free=22G,h_vmem=22G,s_vmem=22G
#normal plugin script
VERSION="5.2.1.39"
VERSION="5.2.2.41"

echo ${DIRNAME}/variant_caller_plugin.py \
--install-dir ${DIRNAME} \
Expand Down
2 changes: 1 addition & 1 deletion plugin/variantCaller/variantCaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.utils.datastructures import SortedDict

class variantCaller(IonPlugin):
version = '5.2.1.39'
version = '5.2.2.41'
envDict = dict(os.environ)

def variantCall(self):
Expand Down
78 changes: 51 additions & 27 deletions plugin/variantCaller/variant_caller_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def prepare_hotspots(options):
if not os.path.exists(options['hotspots_bed_unmerged_local']):
shutil.copy(options['hotspots_bed_unmerged'], options['hotspots_bed_unmerged_local'])

prepare_hotspots_command = 'tvcutils prepare_hotspots'
prepare_hotspots_command = TVCUTILS + ' prepare_hotspots'
prepare_hotspots_command += ' --input-bed "%s"' % options['hotspots_bed_unmerged']
prepare_hotspots_command += ' --reference "%s"' % options['reference_genome_fasta']
prepare_hotspots_command += ' --left-alignment on'
Expand Down Expand Up @@ -345,8 +345,11 @@ def cleanup_options(options):
options['hotspots_bed_merged'] = options['hotspots_bed_unmerged'].replace('/unmerged/detail/','/merged/plain/')
options['hotspots_name'] = os.path.basename(options['hotspots_bed_unmerged'])[:-4]

options['has_targets'] = options['targets_name']
options['has_hotspots'] = options['hotspots_name']
options['has_targets'] = options['targets_bed_unmerged'] != ""
options['has_hotspots'] = options['hotspots_bed_unmerged'] != ""
options['is_targets_barcode_specific'] = False
options['is_hotspot_barcode_specific'] = False
options['is_reference_barcode_specific']= False

reference_genome_fasta_local = os.path.join(TSP_FILEPATH_PLUGIN_DIR, os.path.basename(options['reference_genome_fasta']))
if not os.path.lexists(reference_genome_fasta_local):
Expand Down Expand Up @@ -724,7 +727,7 @@ def variant_caller_pipeline(barcoded_run, multisample, configuration_name, confi
else:
multisample_processed_bam = os.path.join(vc_pipeline_directory,os.path.basename(bams[0]['file'])[:-4] + '_processed.bam')
untrimmed_bams = get_untrimmed_bams(configuration, bams)

prepare_hotspots(configuration['options'])
if configuration['options']['library_type'] == 'tagseq':
sample_name = 'none'
Expand Down Expand Up @@ -780,19 +783,19 @@ def split_results(barcoded_run, configuration_name, configuration, bams):
run_command("cp " + os.path.join(vc_pipeline_directory,'TSVC_variants.vcf') + " " + os.path.join(vc_pipeline_directory,'TSVC_variants_1.vcf'), "Copy TSVC_variants.vcf")
run_command("cp " + os.path.join(vc_pipeline_directory,'TSVC_variants.genome.vcf') + " " + os.path.join(vc_pipeline_directory,'TSVC_variants.genome_1.vcf'), "Copy TSVC_variants.genome.vcf")
else:
cmd = 'tvcutils split_vcf'
cmd = TVCUTILS + ' split_vcf'
cmd += ' --input-vcf ' + os.path.join(vc_pipeline_directory,'small_variants.vcf')
cmd += ' --out-dir ' + vc_pipeline_directory
run_command(cmd, 'Split small_variants.vcf')
cmd = 'tvcutils split_vcf'
cmd = TVCUTILS + ' split_vcf'
cmd += ' --input-vcf ' + os.path.join(vc_pipeline_directory,'small_variants_filtered.vcf')
cmd += ' --out-dir ' + vc_pipeline_directory
run_command(cmd, 'Split small_variants_filtered.vcf')
cmd = 'tvcutils split_vcf'
cmd = TVCUTILS + ' split_vcf'
cmd += ' --input-vcf ' + os.path.join(vc_pipeline_directory,'TSVC_variants.vcf')
cmd += ' --out-dir ' + vc_pipeline_directory
run_command(cmd, 'Split TSVC_variants.vcf')
cmd = 'tvcutils split_vcf'
cmd = TVCUTILS + ' split_vcf'
cmd += ' --input-vcf ' + os.path.join(vc_pipeline_directory,'TSVC_variants.genome.vcf')
cmd += ' --out-dir ' + vc_pipeline_directory
run_command(cmd, 'Split TSVC_variants.genome.vcf')
Expand Down Expand Up @@ -845,7 +848,7 @@ def split_results(barcoded_run, configuration_name, configuration, bams):
if configuration['options']['has_targets']:
cmd += "-b '" + configuration['options']['targets_bed_unmerged'] + "' "
cmd += processed_bam + " | "
cmd += "tvcutils unify_vcf "
cmd += TVCUTILS + " unify_vcf "
cmd += "--novel-tvc-vcf " + os.path.join(vc_pipeline_directory,'TSVC_variants_' + str(dataset_num) + '.vcf') + " "
cmd += "--output-vcf " + os.path.join(results_directory,basename_variants_vcf) + ".gz "
cmd += "--reference-fasta '" + configuration['options']['reference_genome_fasta'] + "' "
Expand Down Expand Up @@ -1009,7 +1012,7 @@ def render_webpages(results_directory, render_context):
out.close()

def generate_variant_allele_cov(configuration, results_directory, processed_bam, untrimmed_bam, bam, render_context):
tvcutils_command = "tvcutils prepare_hotspots"
tvcutils_command = TVCUTILS + " prepare_hotspots"
tvcutils_command += ' --reference "%s"' % configuration['options']['reference_genome_fasta']
tvcutils_command += ' --input-vcf "%s"' % os.path.join(results_directory,BASENAME_VARIANTS_VCF)
tvcutils_command += ' --output-bed "%s"' % os.path.join(results_directory,'TSVC_variants.bed')
Expand Down Expand Up @@ -1201,13 +1204,23 @@ def load_barcode_sample_info(barcoded_run, configuration):

def set_from_plan(configuration, bam, barcode_sample_info):
if configuration['options']['start_mode'] == 'Auto start' and bam['name'] in barcode_sample_info:
my_reference = barcode_sample_info[bam['name']].get('reference','')
my_unmerged_targets = barcode_sample_info[bam['name']].get('targetRegionBedFile','')
my_unmerged_hotspots = barcode_sample_info[bam['name']].get('hotSpotRegionBedFile','')
configuration['options']['is_targets_barcode_specific'] = configuration['options']['is_targets_barcode_specific'] or (my_unmerged_targets != configuration['options']['targets_bed_unmerged'])
configuration['options']['is_hotspot_barcode_specific'] = configuration['options']['is_hotspot_barcode_specific'] or (my_unmerged_hotspots != configuration['options']['hotspots_bed_unmerged'])
configuration['options']['is_reference_barcode_specific'] = configuration['options']['is_reference_barcode_specific'] or (my_reference != configuration['options']['reference_genome_name'])
configuration['options']['sample_name'] = barcode_sample_info[bam['name']].get('sample','')
configuration['options']['reference_genome_name'] = barcode_sample_info[bam['name']].get('reference','')
configuration['options']['targets_bed_unmerged'] = barcode_sample_info[bam['name']].get('targetRegionBedFile','')
configuration['options']['hotspots_bed_unmerged'] = barcode_sample_info[bam['name']].get('hotSpotRegionBedFile','')
configuration['options']['reference_genome_name'] = my_reference
configuration['options']['targets_bed_unmerged'] = my_unmerged_targets
configuration['options']['hotspots_bed_unmerged'] = my_unmerged_hotspots
configuration['options']['nuc_type'] = barcode_sample_info[bam['name']].get('nucleotideType','DNA').upper()
# set the merged bed
# set the merged bed files
configuration['options']['targets_bed_merged'] = configuration['options']['targets_bed_unmerged'].replace('/unmerged/detail/','/merged/plain/')
configuration['options']['hotspots_bed_merged'] = configuration['options']['hotspots_bed_unmerged'].replace('/unmerged/detail/','/merged/plain/')
# has hotspot? has targets?
configuration['options']['has_hotspots'] = configuration['options']['hotspots_bed_unmerged'] != ''
configuration['options']['has_targets'] = configuration['options']['targets_bed_unmerged'] != ''
#TODO: The existance of the files of each sample should be checked!
#TODO: Need to handle the missing barcode case
else:
Expand Down Expand Up @@ -1335,36 +1348,41 @@ def process_configuration(barcoded_run, multisample, configuration_name, configu
process_reference(configuration, bam)

if multisample:
# Run variant_caller_pipeline and process results for multisample
try:
variant_caller_pipeline(barcoded_run, multisample, configuration_name, configuration, configuration['bams'])
split_results(barcoded_run, configuration_name, configuration, configuration['bams'])
except:
traceback.print_exc()
for bam in configuration['bams']:
bam['status'] = 'error'

for bam in configuration['bams']:
set_from_plan(configuration, bam, barcode_sample_info)
try:
bam['summary'] = process_results(barcoded_run, configuration, bam)
load_results_json(barcoded_run, configuration, bam, results_json)
bam['status'] = 'completed'
except:
traceback.print_exc()
bam['status'] = 'error'
bams_processed.append(bam)
else:
# Run variant_caller_pipeline and process results for non-multisample
for bam in configuration['bams']:
set_from_plan(configuration, bam, barcode_sample_info)
bams = []
bams.append(bam)
try:
variant_caller_pipeline(barcoded_run, multisample, bam['name'], configuration, bams)
bam['summary'] = process_results(barcoded_run, configuration, bam)
load_results_json(barcoded_run, configuration, bam, results_json)
bam['status'] = 'completed'
except:
traceback.print_exc()
bam['status'] = 'error'

for bam in configuration['bams']:
set_from_plan(configuration, bam, barcode_sample_info)
try:
bam['summary'] = process_results(barcoded_run, configuration, bam)
load_results_json(barcoded_run, configuration, bam, results_json)
bam['status'] = 'completed'
bams_processed.append(bam)
except:
traceback.print_exc()
bam['status'] = 'error'
bams_processed.append(bam)

def plugin_main():
global PLUGIN_DEV_SKIP_VARIANT_CALLING
global DIRNAME
Expand All @@ -1373,6 +1391,7 @@ def plugin_main():
global TSP_FILEPATH_PLUGIN_DIR
global STARTPLUGIN_JSON
global OUTPUT_FILES
global TVCUTILS

parser = OptionParser()
parser.add_option('-d', '--install-dir', help='Directory containing plugin files', dest='install_dir')
Expand All @@ -1388,7 +1407,12 @@ def plugin_main():
TSP_URLPATH_PLUGIN_DIR = options.output_url
PLUGIN_DEV_SKIP_VARIANT_CALLING = options.skip_tvc
OUTPUT_FILES = []


bin_dir = '%s/bin' % DIRNAME
TVCUTILS = os.path.join(bin_dir,'tvcutils')
if not os.path.exists(TVCUTILS):
TVCUTILS = 'tvcutils'

setup_run()

printtime('')
Expand Down

0 comments on commit 628712b

Please sign in to comment.