Mercurial > repos > jpayne > bioproject_to_srr_2
comparison tests.py @ 4:2d4a2159c74b
planemo upload for repository https://toolrepo.galaxytrakr.org/view/jpayne/bioproject_to_srr_2/556cac4fb538
author | jpayne |
---|---|
date | Fri, 03 May 2024 01:17:43 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:80f1001797c7 | 4:2d4a2159c74b |
---|---|
1 import pytest | |
2 | |
3 from bio2srr import * | |
4 | |
5 | |
6 def test_element_tree_xpath(): | |
7 from xml.etree import ElementTree as xml | |
8 root = xml.fromstring(biosample_example) | |
9 assert root.find(".//Id[@db='BioSample']") is not None | |
10 | |
11 def test_flatten_biosample_xml(): | |
12 d = flatten_biosample_xml(biosample_example) | |
13 assert d['biosample_accession'] == 'SAMN17131268' | |
14 assert d['organism'] == 'Campylobacter jejuni' | |
15 assert d['isolate'] == 'CFSAN091032' | |
16 | |
17 def test_flatten_runs(): | |
18 d = list(flatten_runs(runs_example)) | |
19 assert len(d) == 2 | |
20 | |
21 def test_header_sort_override_consistency(): | |
22 import random | |
23 L = ["C", "B", "A", "taxid", "bioproject"] | |
24 L.sort(key=hso) | |
25 # assert L[0] == "bioproject" | |
26 A = L.copy() | |
27 assert A == L | |
28 R = [] | |
29 for _ in range(100): | |
30 random.shuffle(A) | |
31 A.sort(key=hso) | |
32 R.append(A == L) | |
33 assert all(R) | |
34 | |
35 def test_hso_override(): | |
36 assert header_sort_override("bioproject", "taxid") < 0 | |
37 assert header_sort_override("taxid", "bioproject") > 0 | |
38 assert header_sort_override("taxid", "taxid") == 0 | |
39 | |
40 def test_hso_regular(): | |
41 assert header_sort_override("A", "B") < 0 | |
42 assert header_sort_override("B", "A") > 0 |