Skip to content

Commit 27c154a

Browse files
authored
Support for tsv files that are either formatted like VCF files or Bed Files (#2)
* Support for tsv files that are either formated like VCF files or Bed Files * Add new functional tests
1 parent bb63780 commit 27c154a

20 files changed

+63
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go:
1111
- 1.12.x
1212

1313
script:
14+
- ./functional-test.sh
1415
- cd cmd/check-sort-order
1516
- go test
1617

cmd/check-sort-order/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ func main() {
5858

5959
if strings.HasSuffix(args.Path, ".vcf.gz") {
6060
checkVCF(args.Path, gf)
61-
} else if strings.HasSuffix(args.Path, ".bed.gz") || strings.HasSuffix(strings.ToLower(args.Path), ".bedgraph.gz") {
61+
} else if strings.HasSuffix(args.Path, ".bed.gz") || strings.HasSuffix(strings.ToLower(args.Path), ".bedgraph.gz") || strings.HasSuffix(strings.ToLower(args.Path), ".bedpe.gz"){
62+
checkTab(args.Path, gf, get_vcf_chrom_start)
63+
} else if strings.HasSuffix(strings.ToLower(args.Path), "tsv.gz"){
6264
checkTab(args.Path, gf, get_vcf_chrom_start)
6365
} else {
6466
found := false

functional-test.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
4+
test -e ssshtest || wget -q https://raw.githubusercontent.com/ryanlayer/ssshtest/master/ssshtest
5+
6+
. ssshtest
7+
8+
set -o nounset
9+
10+
go build -o ./check-sort-order cmd/check-sort-order/main.go
11+
12+
13+
## Check vcf file
14+
run check_vcf_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.vcf.gz
15+
assert_exit_code 0
16+
assert_no_stdout
17+
18+
## check bed file
19+
run check_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.bed.gz
20+
assert_exit_code 0
21+
assert_no_stdout
22+
23+
## check gtf file
24+
run check_gtf_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.gtf.gz
25+
assert_exit_code 0
26+
assert_no_stdout
27+
28+
## Check bad sorted bed
29+
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.bad_sort.bed.gz
30+
assert_exit_code 1
31+
assert_in_stderr "chromosomes not in specified sort order: 4, 1 at line 33"
32+
assert_in_stderr "use gsort (https://github.com/brentp/gsort/) to order according to the genome file"
33+
34+
## check a vcf file with a bad header
35+
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.bad_header.vcf.gz
36+
assert_exit_code 1
37+
assert_in_stderr "VCF header line '##fileformat=VCF... not found"
38+
39+
## Check a tsv file that is formated like a vcf file
40+
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_bed_like.tsv.gz
41+
assert_exit_code 0
42+
assert_no_stdout
43+
44+
## Check a tsv file that is formated like a bed file
45+
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_bed_like.tsv.gz
46+
assert_exit_code 0
47+
assert_no_stdout
48+
49+
## Check a tsv file that is not formated correctly
50+
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_bad.vcf_like.tsv.gz
51+
assert_exit_code 1
52+
assert_in_stderr 'strconv.Atoi: parsing "A": invalid syntax'
53+
54+
2.96 KB
Binary file not shown.
443 Bytes
Binary file not shown.

test_files/test_bed_like.tsv.gz

1.66 KB
Binary file not shown.
241 Bytes
Binary file not shown.
7.23 KB
Binary file not shown.
227 Bytes
Binary file not shown.
790 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)