Skip to content

Commit 2b2470f

Browse files
committed
fix handling of reports for no variants
1 parent f3ab27c commit 2b2470f

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

harpy/reports/leviathan_pop.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ emptyfiles <- character()
8080
sv <- data.frame(matrix(ncol=8,nrow=0, dimnames=list(NULL, c("population", "contig", "position_start", "position_end", "length", "type", "n_barcodes", "n_pairs"))))
8181
for(i in statsfiles){
8282
.df <- tryCatch(readvariants(i), error = function(e){return(0)})
83-
if(length(.df)==1){
84-
emptyfiles <- c(emptyfiles, i)
83+
if(nrow(.df)==0){
84+
emptyfiles <- c(emptyfiles, i)
8585
} else {
8686
sv <- rbind(sv, .df)
8787
}

harpy/reports/naibr.Rmd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@ samplename <- gsub(".bedpe", "", basename(infile))
3636
tryCatch(
3737
expr = {
3838
variants <- read.table(infile, header = T)
39+
if (nrow(variants) == 0) {
40+
cat(paste0("There are no variants in the file ", "`", infile, "`"))
41+
knitr::knit_exit()
42+
}
3943
},
4044
error = function(e){
4145
cat(paste0("There are no variants in the file ", "`", infile, "`"))
4246
knitr::knit_exit()
4347
}
4448
)
45-
46-
if (nrow(variants) == 0) {
47-
cat(paste0("There are no variants in the file ", "`", infile, "`"))
48-
knitr::knit_exit()
49-
}
5049
```
5150

5251
```{r package_imports}

harpy/reports/naibr_pop.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ emptyfiles <- character()
9999
sv <- data.frame(matrix(ncol=12,nrow=0, dimnames=list(NULL, c("Population", "Chr1", "Break1", "Chr2", "Break2", "SplitMolecules", "DiscordantReads", "Orientation", "Haplotype", "Score", "PassFilter", "SV"))))
100100
for(i in infiles){
101101
.df <- tryCatch(readvariants(i), error = function(e){return(0)})
102-
if(length(.df)==1){
102+
if(nrow(.df)==0){
103103
emptyfiles <- c(emptyfiles, i)
104104
} else {
105105
sv <- rbind(sv, .df)

0 commit comments

Comments
 (0)