From 8889bd0a3d93266893a21dedefa9f93b8e51e8ef Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 22 Aug 2018 16:18:26 +0200 Subject: [PATCH] Fix various things about the hgv_ldtools tool Unfortnately this doens't produce the test-data output on python 3 and so I added a requiremtn on python 2. (I think the result is probably correct but not deterministic). --- tools/phenotype_association/ldtools.xml | 8 +++++--- tools/phenotype_association/ldtools_wrapper.sh | 11 ++++------- tools/phenotype_association/senatag.py | 14 +++++++++++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/phenotype_association/ldtools.xml b/tools/phenotype_association/ldtools.xml index 9fc188ea934..653d9d0f4e5 100644 --- a/tools/phenotype_association/ldtools.xml +++ b/tools/phenotype_association/ldtools.xml @@ -1,8 +1,10 @@ linkage disequilibrium and tag SNPs - - - ldtools_wrapper.sh rsquare=$rsquare freq=$freq input=$input output=$output + + python + + +'$__tool_directory__/ldtools_wrapper.sh' rsquare=$rsquare freq=$freq input='$input' output='$output' diff --git a/tools/phenotype_association/ldtools_wrapper.sh b/tools/phenotype_association/ldtools_wrapper.sh index fb70a36fc02..331d01bf025 100755 --- a/tools/phenotype_association/ldtools_wrapper.sh +++ b/tools/phenotype_association/ldtools_wrapper.sh @@ -5,7 +5,7 @@ set -e -export PATH=$PATH:$(dirname $0) +SCRIPT_DIR=$(dirname $0) ## pagetag options input= @@ -46,19 +46,16 @@ do done ## run pagetag -pagetag.py --rsquare $rsquare --freq $freq $input snps.txt neighborhood.txt &> /dev/null +python $SCRIPT_DIR/pagetag.py --rsquare $rsquare --freq $freq "$input" snps.txt neighborhood.txt if [ $? -ne 0 ]; then - echo "failed: pagetag.py --rsquare $rsquare --freq $freq $input snps.txt neighborhood.txt" + echo "failed: pagetag.py --rsquare $rsquare --freq $freq \"$input\" snps.txt neighborhood.txt" exit 1 fi ## run sentag -senatag.py neighborhood.txt snps.txt > $output 2> /dev/null +python $SCRIPT_DIR/senatag.py neighborhood.txt snps.txt > "$output" if [ $? -ne 0 ]; then echo "failed: senatag.py neighborhood.txt snps.txt" exit 1 fi -## cleanup -rm -f snps.txt neighborhood.txt - diff --git a/tools/phenotype_association/senatag.py b/tools/phenotype_association/senatag.py index 1fffd53ee83..d4637838d2b 100755 --- a/tools/phenotype_association/senatag.py +++ b/tools/phenotype_association/senatag.py @@ -25,6 +25,7 @@ from __future__ import print_function import heapq import os +from functools import total_ordering from getopt import getopt, GetoptError from sys import argv, exit, stderr @@ -35,6 +36,7 @@ __email__ = "ratan@bx.psu.edu" debug_flag = False +@total_ordering class node: def __init__(self, name): self.name = name @@ -50,8 +52,14 @@ class node: num += 1 return num - def __cmp__(self, other): - return other.num_not_visited() - self.num_not_visited() + def __eq__(self, other): + return self.num_not_visited() == other.num_not_visited() + + def __ne__(self, other): + return not (self == other) + + def __lt__(self, other): + return other.num_not_visited() < self.num_not_visited() def __str__(self): return self.name @@ -165,7 +173,7 @@ def main(ldfile, snpsfile, required, excluded): neighbors[t.name] = list(set(ns)) # find the tag SNPs for this graph - data = g.nodes.values()[:] + data = list(g.nodes.values())[:] heapq.heapify(data) while data: