Skip to content

Commit

Permalink
Support for tsv files that are either formatted like VCF files or Bed…
Browse files Browse the repository at this point in the history
… Files (#2)

* Support for tsv files that are either formated like VCF files or Bed Files

* Add new functional tests
  • Loading branch information
mikecormier authored Jul 22, 2020
1 parent bb63780 commit 27c154a
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go:
- 1.12.x

script:
- ./functional-test.sh
- cd cmd/check-sort-order
- go test

4 changes: 3 additions & 1 deletion cmd/check-sort-order/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func main() {

if strings.HasSuffix(args.Path, ".vcf.gz") {
checkVCF(args.Path, gf)
} else if strings.HasSuffix(args.Path, ".bed.gz") || strings.HasSuffix(strings.ToLower(args.Path), ".bedgraph.gz") {
} else if strings.HasSuffix(args.Path, ".bed.gz") || strings.HasSuffix(strings.ToLower(args.Path), ".bedgraph.gz") || strings.HasSuffix(strings.ToLower(args.Path), ".bedpe.gz"){
checkTab(args.Path, gf, get_vcf_chrom_start)
} else if strings.HasSuffix(strings.ToLower(args.Path), "tsv.gz"){
checkTab(args.Path, gf, get_vcf_chrom_start)
} else {
found := false
Expand Down
54 changes: 54 additions & 0 deletions functional-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash


test -e ssshtest || wget -q https://raw.githubusercontent.com/ryanlayer/ssshtest/master/ssshtest

. ssshtest

set -o nounset

go build -o ./check-sort-order cmd/check-sort-order/main.go


## Check vcf file
run check_vcf_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.vcf.gz
assert_exit_code 0
assert_no_stdout

## check bed file
run check_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.bed.gz
assert_exit_code 0
assert_no_stdout

## check gtf file
run check_gtf_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.gtf.gz
assert_exit_code 0
assert_no_stdout

## Check bad sorted bed
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.bad_sort.bed.gz
assert_exit_code 1
assert_in_stderr "chromosomes not in specified sort order: 4, 1 at line 33"
assert_in_stderr "use gsort (https://github.com/brentp/gsort/) to order according to the genome file"

## check a vcf file with a bad header
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_file.bad_header.vcf.gz
assert_exit_code 1
assert_in_stderr "VCF header line '##fileformat=VCF... not found"

## Check a tsv file that is formated like a vcf file
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_bed_like.tsv.gz
assert_exit_code 0
assert_no_stdout

## Check a tsv file that is formated like a bed file
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_bed_like.tsv.gz
assert_exit_code 0
assert_no_stdout

## Check a tsv file that is not formated correctly
run check_bad_sorted_bed_file ./check-sort-order --genome test_genome_files/genome_sizes.genome test_files/test_bad.vcf_like.tsv.gz
assert_exit_code 1
assert_in_stderr 'strconv.Atoi: parsing "A": invalid syntax'


Binary file added test_files/test_bad.vcf_like.tsv.gz
Binary file not shown.
Binary file added test_files/test_bad.vcf_like.tsv.gz.tbi
Binary file not shown.
Binary file added test_files/test_bed_like.tsv.gz
Binary file not shown.
Binary file added test_files/test_bed_like.tsv.gz.tbi
Binary file not shown.
Binary file added test_files/test_file.bad_header.vcf.gz
Binary file not shown.
Binary file added test_files/test_file.bad_header.vcf.gz.tbi
Binary file not shown.
Binary file added test_files/test_file.bad_sort.bed.gz
Binary file not shown.
Binary file added test_files/test_file.bad_sort.bed.gz.tbi
Binary file not shown.
Binary file added test_files/test_file.bed.gz
Binary file not shown.
Binary file added test_files/test_file.bed.gz.tbi
Binary file not shown.
Binary file added test_files/test_file.gtf.gz
Binary file not shown.
Binary file added test_files/test_file.gtf.gz.tbi
Binary file not shown.
Binary file added test_files/test_file.vcf.gz
Binary file not shown.
Binary file added test_files/test_file.vcf.gz.tbi
Binary file not shown.
Binary file added test_files/test_vcf_like.tsv.gz
Binary file not shown.
Binary file added test_files/test_vcf_like.tsv.gz.tbi
Binary file not shown.
5 changes: 5 additions & 0 deletions test_genome_files/genome_sizes.genome
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#chrom length
1 249250621
2 243199373
3 198022430
4 191154276

0 comments on commit 27c154a

Please sign in to comment.