-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle empty chromosomes, resolved #76 * fixed rfrags indexing and first rfrag omission, resolved #73 * resolved or deprecated #16 * pairtools restrct tests
- Loading branch information
1 parent
a31f52d
commit 5a1cc76
Showing
4 changed files
with
100 additions
and
14 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
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,5 @@ | ||
chr1 0 100 | ||
chr1 100 500 | ||
chr1 500 10000 | ||
chr2 0 200 | ||
chr2 200 10000 |
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,18 @@ | ||
## pairs format v1.0.0 | ||
#shape: upper triangle | ||
#genome_assembly: unknown | ||
#samheader: @SQ SN:chr1 LN:10000 | ||
#samheader: @SQ SN:chr2 LN:10000 | ||
#samheader: @PG ID:bwa PN:bwa VN:0.7.15-r1140 CL:bwa mem -SP /path/ucsc.hg19.fasta.gz /path/1.fastq.gz /path/2.fastq.gz | ||
#chromosomes: chr1 chr2 | ||
#chromsize: chr1 10000 | ||
#chromsize: chr2 10000 | ||
#columns: readID chrom1 pos1 chrom2 pos2 strand1 strand2 pair_type rfrag_test1 rfrag_test2 | ||
readid01 chr1 1 chr2 20 + + UU 0 0 | ||
readid02 chr1 100 chr2 20 - + UU 0 0 | ||
readid03 chr1 100 chr2 20 + + UU 0 0 | ||
readid04 chr1 499 chr2 20 + + UU 1 0 | ||
readid05 chr1 600 chr2 20 + + UU 2 0 | ||
readid06 chr1 1 chr2 200 + + UU 0 0 | ||
readid07 chr1 1 chr2 500 + + UU 0 1 | ||
readid08 chr1 10001 chr2 10001 + + UU 2 1 |
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,52 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import sys | ||
|
||
from nose.tools import assert_raises | ||
|
||
import subprocess | ||
|
||
testdir = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
def test_restrict(): | ||
"""Restrict pairs file""" | ||
mock_pairs_path = os.path.join(testdir, "data", "mock.test-restr.pairs") | ||
mock_rfrag_path = os.path.join(testdir, "data", "mock.rsites.bed") | ||
try: | ||
result = subprocess.check_output( | ||
[ | ||
"python", | ||
"-m", | ||
"pairtools", | ||
"restrict", | ||
"-f", | ||
mock_rfrag_path, | ||
mock_pairs_path, | ||
], | ||
).decode("ascii") | ||
except subprocess.CalledProcessError as e: | ||
print(e.output) | ||
print(sys.exc_info()) | ||
raise e | ||
|
||
# check if the header got transferred correctly | ||
true_header = [l.strip() for l in open(mock_pairs_path, "r") if l.startswith("@")] | ||
output_header = [l.strip() for l in result.split("\n") if l.startswith("#")] | ||
for l in true_header: | ||
assert any([l in l2 for l2 in output_header]) | ||
|
||
# check that the pairs got assigned properly | ||
cols = [x for x in output_header if x.startswith('#columns')][0].split(' ')[1:] | ||
|
||
COL_RFRAG1_TRUE = cols.index('rfrag_test1') | ||
COL_RFRAG2_TRUE = cols.index('rfrag_test2') | ||
COL_RFRAG1_OUTPUT = cols.index('rfrag1') | ||
COL_RFRAG2_OUTPUT = cols.index('rfrag2') | ||
|
||
for l in result.split("\n"): | ||
if l.startswith("#") or not l: | ||
continue | ||
|
||
line = l.split() | ||
assert line[COL_RFRAG1_TRUE] == line[COL_RFRAG1_OUTPUT] | ||
assert line[COL_RFRAG2_TRUE] == line[COL_RFRAG2_OUTPUT] |