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).
This commit is contained in:
mvdbeek
2018-09-05 14:22:00 +02:00
parent 2d732715ff
commit 8889bd0a3d
3 changed files with 20 additions and 13 deletions
+5 -3
View File
@@ -1,8 +1,10 @@
<tool id="hgv_ldtools" name="LD" version="1.0.0">
<description>linkage disequilibrium and tag SNPs</description>
<command interpreter="bash">
ldtools_wrapper.sh rsquare=$rsquare freq=$freq input=$input output=$output
<requirements>
<requirement type="package" version="2.7">python</requirement>
</requirements>
<command detect_errors="exit_code">
'$__tool_directory__/ldtools_wrapper.sh' rsquare=$rsquare freq=$freq input='$input' output='$output'
</command>
<inputs>
@@ -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
+11 -3
View File
@@ -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: