aboutsummaryrefslogtreecommitdiff
path: root/test/requests/mapping_tests.py
blob: 8eb19de7ab1551f6b71e8faf1597776e1ba3afea (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from __future__ import print_function
import re
import copy
import json
import requests
from lxml.html import fromstring

def load_data_from_file():
    filename = "../test/data/input/mapping/1435395_s_at_HC_M2_0606_P.json"
    file_handle = open(filename, "r")
    file_data = json.loads(file_handle.read().encode("utf-8"))
    return file_data

def check_pylmm_tool_selection(host, data):
    print("")
    print("pylmm mapping tool selection")
    data["method"] = "pylmm"
    page = requests.post(host+"/marker_regression", data=data)
    doc = fromstring(page.text)
    form = doc.forms[1]
    assert form.fields["dataset"] == "HC_M2_0606_P"
    assert form.fields["value:BXD1"] == "15.034" # Check value in the file

def check_R_qtl_tool_selection(host, data):
    print("")
    print("R/qtl mapping tool selection")
    headers = {"Content-Type": "application/x-www-form-urlencoded"}
    page = requests.post(host+"/marker_regression", data=data, headers=headers)
    doc = fromstring(page.text)
    form = doc.forms[1]
    assert form.fields["dataset"] == "HC_M2_0606_P"
    assert form.fields["value:BXD1"] == "15.034"

def check_CIM_tool_selection(host, data):
    print("")
    print("CIM mapping tool selection (using reaper)")
    data["method"] = "reaper"
    page = requests.post(host+"/marker_regression", data=data)
    doc = fromstring(page.text)
    form = doc.forms[1]
    assert form.fields["dataset"] == "HC_M2_0606_P"
    assert form.fields["value:BXD1"] == "15.034"

def check_mapping(args_obj, parser):
    print("")
    print("Checking mapping")

    host = args_obj.host
    data = load_data_from_file()
    check_pylmm_tool_selection(host, copy.deepcopy(data))
    check_R_qtl_tool_selection(host, copy.deepcopy(data)) ## Why does this fail?
    check_CIM_tool_selection(host, copy.deepcopy(data))