Skip to content

Commit e720644

Browse files
committed
io tests and pipeline tests
1 parent 6d80714 commit e720644

File tree

7 files changed

+73
-7
lines changed

7 files changed

+73
-7
lines changed

R/io.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ read_fasta = function(x){
5959
head_line = data[seq(1,length(data), 2)]
6060
head_line = substr(head_line, 2, nchar(head_line))
6161

62-
records = data.frame(header = head_line,
62+
records = data.frame(header_data = head_line,
6363
sequence = data[seq(2,length(data), 2)],
6464
stringsAsFactors = FALSE)
6565

R/phmms.r

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
###############################################################################
1313

1414
###############################################################################
15-
#' Nucleotide profile hidden markov model for seqdenoise.
15+
#' Nucleotide profile hidden markov model for debar.
1616
#'
1717
#' This model is stored in the package and was trained on a representitive
1818
#' sample of the barcode of life database (http://www.boldsystems.org/index.php).
@@ -22,7 +22,7 @@
2222
###############################################################################
2323

2424
###############################################################################
25-
#' Example coi5p DNA sequence string
25+
#' Example coi5p DNA sequence string.
2626
#'
2727
#' This string of barcode data is used in the package documentation's examples
2828
#' and within the vignette demonstrating how to use the package.

inst/extdata/small_unittest.fasta

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
>example_read_1
2+
gttcaacaaatcataaagatattggaattctatactttatatttgctatatgagcaggaataattggatcatctataagaataattattcgccttgaattaggatcatgtggctccttgatcaacaatgaccaaatttacaactccatcatcacaggtcacgcatttattataattttctttatagttatgccattcataattgggggattcggtaactttctagtaccattaataattggatcaccagatatagcttatccccgaataagcaacataagattttgactcctacccccatccattactctattaactctaagaagatttatcaactccggggtaggtacaggatgaacagtatacccaccattagcttctaatttattccatagaggggcatctgtagacttagccattttctctcttcatatcgccagagtctcatctatcataggagccattaatttcatttcaacaattattaacataacacacaaaaattttacaatagataaaattcctttgatagtatgagctatctttatcactgctatcttattattatatatctctaccagttttagctggagctatcaccatattattaactgatcgaaacctcaatacatcatttttcgacccggcggggggtggagacccaattctttatcaacatctattctgattttttggacatccatgaagttta
3+
>example_read_2
4+
attcaaccaatcataaagatattggaactctatattttattttcggagcatgatctggaataattggtacagctttaagattaatcatccgaacagaactcggaattcccggatcaataattgggaatgaccaaatctttaatgttattgttacctcacatgcattcatcataatcttcttcatagttataccaattataattgggggattcggaaattgactaatcccaattatattaggagctcctgatatagcatttccacgacttaataatataagattctggttattacctccctccttgtcacttattatttcaagaataatttctgaaagaggagcaggaacaggatgaactgtttatccacccttatcttctaatttagcccatagaggaccaggctgtagacttaacaatttttaggttacatctagcaggaatctcttcgattcttggagcaattaattttattactacaaacatcaatatacgatctagtcttataaaacctgaacgtttaagactattcccatgatcagtttcaatcacagcaattctattactaatctccctacctgtacttgcaggagcaattacaatgcttcttactgaccgaaacattaatacatcattctttgacccagcagggggaggtgacccaattttatatcaacatctattttgattttttggtcaccctgaagttta

inst/extdata/small_unittest.fastq

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@example_read_1
2+
gttcaacaaatcataaagatattggaattctatactttatatttgctatatgagcaggaataattggatcatctataagaataattattcgccttgaattaggatcatgtggctccttgatcaacaatgaccaaatttacaactccatcatcacaggtcacgcatttattataattttctttatagttatgccattcataattgggggattcggtaactttctagtaccattaataattggatcaccagatatagcttatccccgaataagcaacataagattttgactcctacccccatccattactctattaactctaagaagatttatcaactccggggtaggtacaggatgaacagtatacccaccattagcttctaatttattccatagaggggcatctgtagacttagccattttctctcttcatatcgccagagtctcatctatcataggagccattaatttcatttcaacaattattaacataacacacaaaaattttacaatagataaaattcctttgatagtatgagctatctttatcactgctatcttattattatatatctctaccagttttagctggagctatcaccatattattaactgatcgaaacctcaatacatcatttttcgacccggcggggggtggagacccaattctttatcaacatctattctgattttttggacatccatgaagttta
3+
+
4+
~~y~~~~~~Q~~~~~~q~~~~~~~~~`~~~~~~~~~~i~~~~~n~~~~~~~~~~~~~~~~~~~~y~~~~~~~~~~~~~~~~~~~~~~~q~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~F~~U~~~~~~~~~~~~~~~~~~~~~~~~~~~~m~~~~~~~~~~d~~~N~~~~~{~~~~~~~z~~~~x~~~~~~d~~~~~~~~~~~~V~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~f~~su~'O~~k~~~~~~~~~~a~~~~~~~~~~~~4~~~~~~u07~~~~~~~~~~~~~~~~~~~~~F~~~~~~~~~~~~{~~~~~~~~~~~~~~~~~~~~~~~~n~~~~~o~~~~~~~~w~~v~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~T~~~~~~~~~~~~~~~~u~~~~~~~~~~~~~~~~~~~o~~~~~~~~~~m~~~~k~~~~~z~p~~~~y~~~~~~~~~~~~~~P~~~J~~~~~~~~~~~~p~V~~~~\~~~~Z`~~~~~~~~~~~~}~~~~~~~~~~~~~w~~~~~~~10~~~~~~~~~~~~~~~U~~~~{?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~f~~~~~~~~~~~~~~~~~I~~~~~i~~~~~~~~a~~~~~~~~~~c~~~~~o~~~~~~~~~~~~~~~~~~~~~~A~ni~xS~~`F~~~~~~[~
5+
@example_read_2
6+
attcaaccaatcataaagatattggaactctatattttattttcggagcatgatctggaataattggtacagctttaagattaatcatccgaacagaactcggaattcccggatcaataattgggaatgaccaaatctttaatgttattgttacctcacatgcattcatcataatcttcttcatagttataccaattataattgggggattcggaaattgactaatcccaattatattaggagctcctgatatagcatttccacgacttaataatataagattctggttattacctccctccttgtcacttattatttcaagaataatttctgaaagaggagcaggaacaggatgaactgtttatccacccttatcttctaatttagcccatagaggaccaggctgtagacttaacaatttttaggttacatctagcaggaatctcttcgattcttggagcaattaattttattactacaaacatcaatatacgatctagtcttataaaacctgaacgtttaagactattcccatgatcagtttcaatcacagcaattctattactaatctccctacctgtacttgcaggagcaattacaatgcttcttactgaccgaaacattaatacatcattctttgacccagcagggggaggtgacccaattttatatcaacatctattttgattttttggtcaccctgaagttta
7+
+
8+
~Ts~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~u~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~l~8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~~~~~~~~~~~e~~~~~~~~~~~~~~~~~

man/example_nt_string.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/nt_PHMM.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_io.r

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
test_that("Sequence files are read in properly.", {
1+
test_that("Sequence files are read, denoised and written properly.", {
22

33
fasta_real_file = system.file('extdata/coi_sequel_data_subset.fasta', package = 'debar')
44
data1 = read_fasta(fasta_real_file)
@@ -17,5 +17,59 @@ test_that("Sequence files are read in properly.", {
1717

1818
#all.equal(dim(data3), c(250,2))
1919
expect_equal(all.equal(dim(data3), c(250,2)), TRUE)
20+
21+
#test writing to fastq file using a temp
22+
temp = tempfile()
23+
on.exit(unlink(temp))
2024

21-
})
25+
#write to a fastq when no quality data
26+
x1 = denoise(data1$sequence[[1]], data1$header[[1]], double_pass = FALSE, dir_check = FALSE)
27+
write_fastq(x1 , outfile = temp, keep_phred = FALSE, phred_placeholder = "~")
28+
29+
#write to fastq with quality data
30+
x2 = denoise(data2$sequence[[1]], name = data2$header[[1]], phred = data2$quality[[1]], double_pass = FALSE, dir_check = FALSE)
31+
write_fastq(x2 , outfile = temp)
32+
33+
#test writing to fasta using a temp
34+
temp2 = tempfile()
35+
on.exit(unlink(temp2))
36+
37+
#write to a fastq when no quality data
38+
x3 = denoise(data1$sequence[[1]], data1$header[[1]], double_pass = FALSE, dir_check = FALSE)
39+
write_fastq(x3 , outfile = temp2, keep_phred = FALSE, phred_placeholder = "~")
40+
41+
#write to fastq with quality data
42+
x4 = denoise(data2$sequence[[1]], name = data2$header[[1]], phred = data2$quality[[1]], double_pass = FALSE, dir_check = FALSE)
43+
write_fastq(x4 , outfile = temp2)
44+
45+
#test the full pipeline on a small sequence datasets
46+
# have the
47+
fastq_test_file = system.file('extdata/small_unittest.fastq', package = 'debar')
48+
fasta_test_file = system.file('extdata/small_unittest.fasta', package = 'debar')
49+
50+
#
51+
# Write to a fasta file
52+
#
53+
temp3 = file.path(tempdir(), "temp_out.fastq")
54+
on.exit(unlink(temp3))
55+
56+
denoise_file(fastq_test_file, outfile = temp3,
57+
log_file = FALSE, keep_rejects = FALSE, double_pass = FALSE, dir_check = FALSE)
58+
59+
denoise_file(fasta_test_file, outfile = temp3, file_type = 'fasta', keep_phred = FALSE, phred_placeholder = "~",
60+
log_file = FALSE, keep_rejects = FALSE, double_pass = FALSE, dir_check = FALSE)
61+
62+
63+
#
64+
# Write to a fasta file
65+
#
66+
temp4 = file.path(tempdir(), "temp_out.fasta")
67+
on.exit(unlink(temp4))
68+
69+
denoise_file(fasta_test_file, outfile = temp4, file_type = 'fasta', keep_phred = FALSE, phred_placeholder = "~",
70+
log_file = FALSE, keep_rejects = FALSE, double_pass = FALSE, dir_check = FALSE)
71+
72+
denoise_file(fastq_test_file, outfile = temp4,
73+
log_file = FALSE, keep_rejects = FALSE, double_pass = FALSE, dir_check = FALSE)
74+
75+
})

0 commit comments

Comments
 (0)