aboutsummaryrefslogtreecommitdiff
path: root/README.org
blob: 81626179fa7e391a977622de81c335c729c8e076 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#+STARTUP: inlineimages
#+TITLE: GeneNetwork Quality Control Application

** Project Goals

The project seeks to handle the checking of data files for correct syntax and
other errors before allowing the code to be uploaded.

The files are *"tab-separated"* values (TSV) files, and must conform to the
following criteria:

*** Line-Level Checks

- Must be tab-separated
-

*** Cell-Level Checks

- No empty data cells
- no data cells with spurious characters like `eeeee`, `5.555iloveguix`, etc.
- decimal numbers must conform to the following criteria:
-   - when checking an average file decimal numbers must contain exactly three places to the right side of the dot.
-   - when checking a standard error file decimal numbers must contain six or greater places to the right side of the dot.
-   - there must be a number to the left side of the dot (e.g. 0.55555 is allowed but .55555 is not).
- check line endings to make sure they are Unix and not DOS
- check strain headers against a source of truth (see strains.csv)

** Development

For reproducibility, this project is developed using guix.

To launch a guix shell for development, do
#+BEGIN_SRC shell
  guix shell --container --network --pure --manifest=manifest.scm --share=/some/host/directory=/the/upload/directory
#+END_SRC
which environment that is isolated from the rest of your system.

We share a host directory with the container (that is writeable by the user that
started the web application) to serve as the upload directory for the
application.

*** Run the CLI version

To run the CLI version of the application, we need to set up the correct ~PYTHONPATH~
#+BEGIN_SRC shell
export PYTHONPATH="${PYTHONPATH:+$PYTHONPATH:}$(pwd)"
#+END_SRC
which enables us to run the script with
#+BEGIN_SRC shell
python3 scripts/qc.py --help
#+END_SRC

Without setting up the ~PYTHONPATH~ environment variable, you might get an error
like the following
#+BEGIN_EXAMPLE shell
$ python3 scripts/qc.py --help
Traceback (most recent call last):
  File "/home/frederick/genenetwork/gnqc_py/scripts/qc.py", line 8, in <module>
    from quality_control.errors import ParseError
ModuleNotFoundError: No module named 'quality_control'
#+END_EXAMPLE

*NOTE*: Setting up the ~PYTHONPATH~ environment variable is only necessary for
the development environment. It *MUST NOT* require that the end-user set this up
at all!

*** Run the web version

To run the web-version of the qc app in development mode, you need to set up a
few environment variables
#+BEGIN_SRC shell
export FLASK_APP=wsgi.py
export FLASK_ENV=development
export QCAPP_INSTANCE_PATH=/path/to/directory/with/config.py
#+END_SRC
then you can run the application with
#+BEGIN_SRC shell
flask run
#+END_SRC

You then need to manually start the *rq* worker(s)
#+BEGIN_SRC shell
rq worker qcapp_queue
#+END_SRC

*** Checks

Run tests with:
#+BEGIN_SRC shell
  pytest
#+END_SRC

To run the linter over the code base, run:
#+BEGIN_SRC shell
  pylint tests quality_control qc_app
#+END_SRC

To check for correct type usage in the application, run:
#+BEGIN_SRC shell
  mypy --show-error-codes .
#+END_SRC

** Running QC

*** Installing QC

The application can be installed using guix by pointing to the [[./guix.scm][guix.scm]] file as
follows:
#+BEGIN_SRC shell
guix package [-p /path/to/qc/profile] -f guix.scm
#+END_SRC

Once installed, the sections that follow show how to use the *qc* application

*** Command-Line Version

Install the application as shown in the [[Installing QC]] section above.

To run qc against a file, the syntax is:
#+BEGIN_SRC shell
 qc [--strainsfile <strainsfile-path>] [--verbose] <filetype> <filepath>
#+END_SRC
where
- ~<filetype>~ is one of "*average*" or "*standard-error*"
- ~<filepath>~ is either an absolute path to the file, or a path relative to the
  current working directory
- if the ~--strainsfile~ option is not provided, it will default to the one in
  the root directory of this repository
- the ~--verbose~ option is a flag, defaulting to ~False~ that controls the
  display of optional progress messages

To view the usage information for the application, run
#+BEGIN_SRC shell
qc --help
#+END_SRC

*** Web Version

Coming soon...