Beispiel #1
0
def test_batch_ptm_ppi_csv():

    # construct the body
    substrates = [
        models.QuerySubstrate("Q15796", "K", "19"),
        models.QuerySubstrate("Q15796", "T", "8"),
        models.QuerySubstrate("P04637", "K", "120"),
        models.QuerySubstrate("P04637", "S", "149"),
        models.QuerySubstrate("P04637", "S", "378"),
        models.QuerySubstrate("P04637", "S", "392"),
        models.QuerySubstrate("P42356", "S", "199")
    ]

    body_str = json.dumps(substrates,
                          default=lambda o: o.__dict__,
                          indent=4,
                          sort_keys=True)

    headers = {"Accept": "text/plain"}

    result = requests.post(url='{host}/batch_ptm_ppi'.format(host=host),
                           data=body_str,
                           headers=headers)

    # assert if request was successful
    assert result.status_code == 200, result.text

    # parse the returned response
    returned_ptmppi = helper.load_csv_from_string(result.text)

    # assert that returned response is not empty
    assert len(returned_ptmppi) is not 0
Beispiel #2
0
def test_browse_csv():
    params = {
        "term_type":
        "All",
        "start_index":
        "0",
        "end_index":
        "120",
        "ptm_type": [
            "Acetylation", "C-Glycosylation", "Myristoylation",
            "Ubiquitination", "N-Glycosylation", "S-Glycosylation",
            "Phosphorylation", "S-Nitrosylation", "O-Glycosylation",
            "Methylation", "Sumoylation"
        ],
        "role":
        "Enzyme or Substrate",
        "organism": [10090, 9606]
    }

    headers = {"Accept": "text/plain"}

    result = requests.get('{host}/browse'.format(host=host),
                          params=params,
                          headers=headers)

    # assert if request was successful
    assert result.status_code == 200, result.text

    # assert if header contains count
    assert result.headers.get("count") is not None

    # parse the returned response
    returned_search_results = helper.load_csv_from_string(result.text)

    assert len(returned_search_results) == 120
Beispiel #3
0
def test_get_ptmppi_csv():
    url = "{host}/Q15796/ptmppi".format(host=host)

    headers = {"Accept": "text/plain"}

    result = requests.get(url=url, headers=headers)

    # assert if request was successful
    assert result.status_code == 200, result.text

    # parse the returned response
    returned_ptmppis = helper.load_csv_from_string(result.text)

    # assert that returned response is not empty
    assert len(returned_ptmppis) is not 0
Beispiel #4
0
def test_substrate_csv():
    headers = {"Accept": "text/plain", "Origin": host}

    result = requests.get('{host}/Q15796/substrate'.format(host=host),
                          headers=headers)

    # assert response == Ok
    assert result.status_code == 200, result.text

    # parse the result
    returned_substrates = helper.load_csv_from_string(result.text)
    helper.sanitize_substrates(returned_substrates)

    # assert that returned response is not empty
    assert len(returned_substrates) is not 0
Beispiel #5
0
def test_search_csv():
    params = {
        "search_term":
        "smad2",
        "term_type":
        "All",
        "ptm_type": [
            "Acetylation", "C-Glycosylation", "Myristoylation",
            "Ubiquitination", "N-Glycosylation", "S-Glycosylation",
            "Phosphorylation", "S-Nitrosylation", "O-Glycosylation",
            "Methylation", "Sumoylation"
        ],
        "role":
        "Enzyme or Substrate",
        "organism": [10090, 9606]
    }

    headers = {"Accept": "text/plain"}

    result = requests.get('{host}/search'.format(host=host),
                          params=params,
                          headers=headers)

    # assert if request was successful
    assert result.status_code == 200, result.text

    # assert if header contains count
    assert result.headers.get("count") is not None

    # parse the returned response
    returned_search_results = helper.load_csv_from_string(result.text)

    # load the expected response
    expected_search_results = helper.load_csv_from_file("search.csv")

    for index, search_result in enumerate(expected_search_results):
        assert (search_result in returned_search_results
                ) == True, "Item at index: {index} not found".format(
                    index=index)