Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pwwang committed Oct 21, 2019
1 parent a0ae70e commit b1f4e1a
Show file tree
Hide file tree
Showing 23 changed files with 737 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .tagitrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
changelog = docs/CHANGELOG.md

; Whether publish the package after the tag pushed to server.
publish = py:True
publish = py:False

; Whether check the version (__version__) in source file.
checksource = py:False
Expand Down
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: python
matrix:
include:
- python: 3.6
- python: 3.7
dist: xenial
before_install:
- pip install poetry
- sudo apt-get update
- sudo apt-get install r-base
- sudo R -e 'install.packages(c("ggplot2", "ggrepel"))'
install:
- poetry install -v
script:
- pytest tests/ -s
after_success: |
if [ "$TRAVIS_PYTHON_VERSION" == "3.7" ]; then
python-codacy-coverage -r .coverage.xml
fi
deploy:
provider: script
script: poetry publish --build -u $PYPI_USER -p $PYPI_PASSWORD
on:
tags: true
condition: "$TRAVIS_PYTHON_VERSION == 3.7"
10 changes: 4 additions & 6 deletions docs/cliargs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ Description:
vcfstats v0.0.1: Powerful VCF statistics.

Usage:
vcfstats <--vcf AUTO> <--outdir AUTO> [OPTIONS]
vcfstats <--vcf AUTO> <--outdir AUTO> <-f LIST> <-t LIST> [OPTIONS]

Required options:
-v, --vcf <AUTO> - The VCF file
-o, --outdir <AUTO> - The output directory.
-f, --formula <LIST> - The formulas for plotting in format of [Y] ~ [X],
where [Y] or [X] should be an entry or an aggregation
-t, --title <LIST> - The title of each figure, will be used to name the output files.

Optional options:
--loglevel <STR> - The logging level. Default: 'INFO'
Expand All @@ -29,11 +32,6 @@ Optional options:
Default: False
--macro <AUTO> - User-defined macro file.
Default: None
-f, --formula <LIST> - The formulas for plotting in format of [Y] ~ [X],
where [Y] or [X] should be an entry or an aggregation
Default: []
-t, --title <LIST> - The title of each figure, will be used to name the output files.
Default: []
--ggs <LIST> - Extra ggplot2 expression for each plot
Default: []
--devpars <DICT> - The device parameters for plots.
Expand Down
10 changes: 7 additions & 3 deletions docs/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ We are using `cyvcf2` to get variant information, please refer to its [API docum

!!! note

`vcf` is initialized with `gts012 = True`, which is not the default value of `cyvcf2`
`vcf` is initialized with `gts012 = True`, which is not the default value of `cyvcf2`. \
`gts012 = True` indicates that genotype 2 as `HOM_ALT` and 3 as `UNKNOWN`.


## Shortcuts for macro decorators
Expand Down Expand Up @@ -78,6 +79,7 @@ While when you use it, you can specify macros as filter and group for it. For ex
## Built-in macros
```python


@categorical
def VARTYPE(variant):
"""Variant type, one of deletion, indel, snp or sv"""
Expand Down Expand Up @@ -106,7 +108,7 @@ def GTTYPEs(variant):
@categorical
def FILTER(variant):
"""Get the FILTER of a variant."""
return variant.FILTER
return variant.FILTER or 'PASS'

@categorical
def SUBST(variant):
Expand All @@ -128,7 +130,7 @@ def QUAL(variant):
"""Variant quality from QUAL field."""
return variant.QUAL

@continuous
@continuous(alias = 'DPs')
def DEPTHs(variant):
"""Get the read-depth for each sample as a numpy array."""
return [sum(dp) for dp in variant.format('DP')]
Expand Down Expand Up @@ -161,6 +163,8 @@ def SUM(entries):
@aggregation(alias = 'AVG')
def MEAN(entries):
"""Get the mean of the values"""
if not entries:
return 0.0
return sum(entries) / len(entries)
```

Expand Down
Binary file modified examples/Allele_frequency_on_chromosome_1_2.density.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Allele_frequency_on_each_chromosome.violin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Number_of_substitutions_of_SNPs.col.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Number_of_substitutions_of_SNPs_(passed).col.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Overall_allele_frequency_distribution.histogram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Types_of_variants_on_each_chromosome_1.pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified examples/Types_of_variants_on_whole_genome.pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/sample.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
1 10329 . ACCCC ACCC 26.4 MinMQ INDEL;DP=315;VDB=0.0160;AF1=0.2047;AC1=2;DP4=2,42,9,16;MQ=17;FQ=29.3;PV4=0.0011,1,0.061,1;AN=8;AC=1 GT:PL:DP:SP:GQ 0/0:0,4,68:22:10:7 0/0:2,0,16:7:0:3 0/0:0,15,61:18:0:17 0/1:46,0,34:22:7:40
1 10352 . TACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC 253 MinMQ INDEL;DP=413;VDB=0.0226;AF1=0.8598;AC1=7;DP4=7,17,13,44;MQ=15;FQ=4.35;PV4=0.58,1,1,0.0055;AN=8;AC=7 GT:PL:DP:SP:GQ 1/1:67,6,0:18:2:11 1/1:14,7,0:12:0:12 1/1:111,22,0:23:0:26 0/1:83,0,22:28:2:18
1 10492 . C T 999 PASS DP=213;VDB=0.0102;AF1=0.375;AC1=3;DP4=84,74,34,19;MQ=32;FQ=999;PV4=0.2,0.11,0.057,0.13;AN=8;AC=3 GT:PL:DP:SP:GQ 0/1:85,0,255:57:3:86 0/0:0,123,255:41:0:99 0/1:255,0,255:47:0:99 0/1:114,0,255:66:4:99
1 10583 . G A 20 PASS DP=134;VDB=0.0071;AF1=0.1242;AC1=1;DP4=78,41,6,6;MQ=32;FQ=20;PV4=0.35,0.29,0.052,1;AN=8;AC=1 GT:PL:DP:SP:GQ 0/1:26,0,227:40:8:21 0/0:0,35,255:21:0:40 0/0:0,108,255:36:0:99 0/0:0,21,255:34:0:26
1 10583 . G A,C 20 PASS DP=134;VDB=0.0071;AF1=0.1242;AC1=1;DP4=78,41,6,6;MQ=32;FQ=20;PV4=0.35,0.29,0.052,1;AN=8;AC=1 GT:PL:DP:SP:GQ 0/1:26,0,227:40:8:21 2/2:0,35,255:21:0:40 0/0:0,108,255:36:0:99 0/0:0,21,255:34:0:26
1 10797 . CAGA CAGAGA 90.4 MinMQ INDEL;DP=37;VDB=0.0243;AF1=0.2819;AC1=2;DP4=7,3,0,6;MQ=29;FQ=93.3;PV4=0.011,1,1,1;AN=8;AC=2 GT:PL:DP:SP:GQ 0/0:0,9,104:3:0:10 0/0:0,6,39:2:0:8 0/1:59,0,36:5:0:43 0/1:56,0,32:6:4:39
1 10821 . T A 49.7 PASS DP=9;VDB=0.0091;AF1=1;AC1=5;DP4=1,3,0,4;MQ=12;FQ=7.75;PV4=1,1,1,1;AN=8;AC=6 GT:PL:DP:SP:GQ 1/1:42,9,0:33:0:20 0/1:0,3,4:1:0:2 1/1:12,1,0:2:0:4 0/1:0,6,8:2:0:2
2 14907 . A G 999 MinMQ DP=461;VDB=0.0384;AF1=0.5;G3=8.874e-45,1,8.011e-40;HWE=0.0185;AC1=4;DP4=101,122,129,102;MQ=25;FQ=999;PV4=0.031,0.011,1,1;AN=8;AC=4 GT:PL:DP:SP:GQ 0/1:225,0,255:133:0:99 0/1:213,0,225:91:20:99 0/1:255,0,188:104:0:99 0/1:255,0,208:126:4:99
Expand Down
Loading

0 comments on commit b1f4e1a

Please sign in to comment.