File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/twobit Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change 11package org .biojava .nbio .genome .parsers .twobit ;
22
3+ import org .biojava .nbio .core .util .FileDownloadUtils ;
4+
35import java .io .File ;
6+ import java .io .IOException ;
47import java .net .MalformedURLException ;
58import java .net .URL ;
69
912 */
1013public class SimpleTwoBitFileProvider {
1114
12- private File twoBitFileLocalLocation ;
13- private String genomeAssembly ;
14-
15- public SimpleTwoBitFileProvider (File twoBitFileLocalLocation , String genomeAssembly ) throws MalformedURLException {
16-
17- this .twoBitFileLocalLocation = twoBitFileLocalLocation ;
18- this .genomeAssembly = genomeAssembly ;
15+ public static void downloadIfNoTwoBitFileExists (File twoBitFileLocalLocation , String genomeAssembly ) throws IOException {
1916
2017 if ( ! twoBitFileLocalLocation .exists () ) {
2118
19+ // download to a temporary file
20+ File tmp = File .createTempFile ("" ,".2bit" );
2221 URL twoBitFileURL = getTwoBitURL (genomeAssembly );
2322
23+ // 2bit files are large and take a while to download
24+ FileDownloadUtils .downloadFile (twoBitFileURL , tmp );
2425
26+ // after the download rename
27+ tmp .renameTo (twoBitFileLocalLocation );
2528
2629 }
2730 }
You can’t perform that action at this time.
0 commit comments