-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9 set up unit testing workflow (#10)
Set up basic unit tests for copy number variant detection
- Loading branch information
1 parent
4b7f3c4
commit 7456f53
Showing
26 changed files
with
409 additions
and
5,833 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: build tests | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up conda environment | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
activate-environment: contextsv | ||
environment-file: environment.yml | ||
python-version: 3.9 | ||
auto-activate-base: false | ||
|
||
- name: Install samtools and bcftools using sudo apt-get | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y samtools bcftools | ||
- name: Build C++ code | ||
shell: bash --login {0} # --login enables PATH variable access | ||
run: | | ||
make | ||
- name: Run unit tests | ||
shell: bash --login {0} | ||
run: | | ||
mkdir -p tests/output | ||
python -m pytest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
INCL_DIR := $(CURDIR)/include | ||
SRC_DIR := $(CURDIR)/src | ||
LIB_DIR := $(CURDIR)/lib | ||
|
||
|
||
all: | ||
# Generate the SWIG wrapper (C++ -> Python) | ||
swig -c++ -python -I$(INCL_DIR) -o $(SRC_DIR)/swig_wrapper.cpp -outdir $(LIB_DIR) $(SRC_DIR)/swig_wrapper.i | ||
|
||
# Compile the SWIG wrapper using setuptools | ||
python setup.py build_ext --build-lib $(LIB_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
# ContextSV | ||
An alignment-based, generalized structural variant caller for long-read sequencing/mapping data | ||
An alignment-based, generalized structural variant caller for long-read | ||
sequencing/mapping data | ||
|
||
[![build tests](https://github.com/WGLab/ContextSV/actions/workflows/build-tests.yml/badge.svg)](https://github.com/WGLab/ContextSV/actions/workflows/build-tests.yml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
""" | ||
__main__.py: Run the program. | ||
""" | ||
|
||
import os | ||
import argparse | ||
from lib import contextsv | ||
|
||
def main(): | ||
|
||
# Grab the command line arguments using argparse. | ||
parser = argparse.ArgumentParser( | ||
description="ContextSV: A tool for integrative structural variant detection." | ||
) | ||
parser.add_argument( | ||
"-b", "--bam", | ||
help="The path to the BAM file.", | ||
required=True | ||
) | ||
parser.add_argument( | ||
"-s", "--snps", | ||
help="The path to the SNPs file.", | ||
required=True | ||
) | ||
parser.add_argument( | ||
"-o", "--output", | ||
help="The path to the output file.", | ||
required=True | ||
) | ||
parser.add_argument( | ||
"-r", "--region", | ||
help="The region to analyze.", | ||
required=True | ||
) | ||
|
||
# Get the command line arguments. | ||
args = parser.parse_args() | ||
|
||
# Run the program. | ||
print("Running contextsv with the following arguments:") | ||
print("BAM: {}".format(args.bam)) | ||
print("SNPs: {}".format(args.snps)) | ||
print("Output: {}".format(args.output)) | ||
print("Region: {}".format(args.region)) | ||
|
||
contextsv.run( | ||
args.bam, | ||
args.snps, | ||
args.output, | ||
args.region | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# Run the program. | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: contextsv | ||
channels: | ||
- bioconda | ||
- anaconda | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- python | ||
- numpy | ||
- htslib | ||
- swig | ||
- pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// contextsv.h | ||
// Main header file for the contextsv library. | ||
// | ||
|
||
#ifndef CONTEXTSV_H | ||
#define CONTEXTSV_H | ||
|
||
#include "khmm.h" | ||
#include "common.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#endif // CONTEXTSV_H |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
""" | ||
setup.py: | ||
This file is used to install the package. | ||
""" | ||
|
||
print("Running setup.py...") | ||
|
||
import os | ||
import glob | ||
from setuptools import setup, find_packages, Extension | ||
|
||
|
||
# Set the project metadata | ||
name = "contextsv" | ||
version = "0.0.1" | ||
author = "WGLab" | ||
description = "ContextSV: A tool for integrative structural variant detection." | ||
|
||
# Get the conda environment's include path | ||
conda_prefix = os.environ.get("CONDA_PREFIX") | ||
if conda_prefix is None: | ||
raise Exception("CONDA_PREFIX is not set.") | ||
conda_include_dir = os.path.join(conda_prefix, "include") | ||
|
||
print("CONDA_PREFIX: {}".format(conda_prefix)) # DEBUG | ||
print("include_dir: {}".format(conda_include_dir)) # DEBUG | ||
|
||
# Get the conda environment's lib path | ||
conda_lib_dir = os.path.join(conda_prefix, "lib") | ||
|
||
print("lib_dir: {}".format(conda_lib_dir)) # DEBUG | ||
|
||
# Set the project dependencies | ||
src_dir = "src" | ||
src_files = glob.glob(os.path.join(src_dir, "*.cpp")) | ||
include_dir = "include" | ||
include_files = glob.glob(os.path.join(include_dir, "*.h")) | ||
|
||
# Set up the extension | ||
ext = Extension( | ||
name="_" + name, | ||
sources=src_files, | ||
include_dirs=[include_dir, conda_include_dir], | ||
extra_compile_args=["-std=c++11"], | ||
language="c++", | ||
libraries=["hts"], | ||
library_dirs=[conda_lib_dir] | ||
) | ||
|
||
# Set up the module | ||
setup( | ||
name=name, | ||
version=version, | ||
author=author, | ||
description=description, | ||
ext_modules=[ext], | ||
py_modules=[name], | ||
packages=find_packages(), | ||
test_suite="tests", | ||
entry_points={ | ||
"console_scripts": [ | ||
"contextsv = contextsv:main" | ||
] | ||
} | ||
) | ||
|
Oops, something went wrong.