@@ -841,23 +841,50 @@ seqVCF2GDS <- function(vcf.fn, out.fn, header=NULL,
841841 # unlimit the last one
842842 psplit [[2L ]][length(psplit [[2L ]])] <- - 1L
843843
844+ # show information
845+ update_info <- function (i )
846+ {
847+ .cat(" |> " , i , " [" , .tm(), " done]" )
848+ flush.console()
849+ NULL
850+ }
851+ if (! isTRUE(verbose )) update_info <- " none"
852+
853+ # reset memory before calling parallel
854+ gc(FALSE , reset = TRUE , full = TRUE )
855+
844856 # conversion in parallel
845857 seqParallel(parallel , NULL , FUN = function (
846858 vcf.fn , header , storage.option , info.import , fmt.import ,
847859 genotype.var.name , ignore.chr.prefix , scenario , optim ,
848860 raise.err , ptmpfn , psplit , variant_count )
849861 {
850862 i <- process_index # the process id, starting from one
851- SeqArray :: seqVCF2GDS(vcf.fn , ptmpfn [i ], header = oldheader ,
852- storage.option = storage.option , info.import = info.import ,
853- fmt.import = fmt.import , genotype.var.name = genotype.var.name ,
854- ignore.chr.prefix = ignore.chr.prefix ,
855- start = psplit [[1L ]][i ], count = psplit [[2L ]][i ],
856- variant_count = variant_count ,
857- optimize = optim , scenario = scenario , raise.error = raise.err ,
858- digest = FALSE , parallel = FALSE , verbose = FALSE )
859- invisible () # return
860- }, split = " none" ,
863+ tryCatch(
864+ {
865+ SeqArray :: seqVCF2GDS(vcf.fn , ptmpfn [i ], header = oldheader ,
866+ storage.option = storage.option , info.import = info.import ,
867+ fmt.import = fmt.import ,
868+ genotype.var.name = genotype.var.name ,
869+ ignore.chr.prefix = ignore.chr.prefix ,
870+ start = psplit [[1L ]][i ], count = psplit [[2L ]][i ],
871+ variant_count = variant_count ,
872+ optimize = optim , scenario = scenario ,
873+ raise.error = raise.err ,
874+ digest = FALSE , parallel = FALSE , verbose = FALSE )
875+ i # return the process index
876+ }, error = function (e ) {
877+ # capture full traceback
878+ trace <- capture.output({
879+ cat(" Error: " , e $ message , " \n " , sep = " " )
880+ traceback()
881+ })
882+ con <- file(paste0(ptmpfn [i ], " .progress.txt" ), open = " at" )
883+ writeLines(trace , con )
884+ close(con )
885+ stop(e $ message )
886+ })
887+ }, split = " none" , .combine = update_info ,
861888 vcf.fn = vcf.fn , header = header , storage.option = storage.option ,
862889 info.import = info.import , fmt.import = fmt.import ,
863890 genotype.var.name = genotype.var.name ,
@@ -876,7 +903,7 @@ seqVCF2GDS <- function(vcf.fn, out.fn, header=NULL,
876903
877904
878905 # ######################################################################
879- # create a GDS file
906+ # create a new GDS file
880907
881908 gfile <- createfn.gds(out.fn )
882909 on.exit({ if (! is.null(gfile )) closefn.gds(gfile ) }, add = TRUE )
0 commit comments