@@ -179,9 +179,9 @@ public void setSequenceId(Integer sequenceId)
179179
180180 public File getBaseDir ()
181181 {
182- File jbrowseDir = new File (JBrowseManager .get ().getBaseDir (getContainerObj (), needsProcessing ()), "resources" );
182+ File jbrowseDir = FileUtil . appendName (JBrowseManager .get ().getBaseDir (getContainerObj (), needsProcessing ()), "resources" );
183183
184- return needsProcessing () ? new File (jbrowseDir , getObjectId ()) : null ;
184+ return needsProcessing () ? FileUtil . appendName (jbrowseDir , getObjectId ()) : null ;
185185 }
186186
187187 public String getLabel ()
@@ -823,28 +823,29 @@ public File prepareResource(User u, Logger log, boolean throwIfNotPrepared, bool
823823 throw new PipelineJobException ("No ExpData for JsonFile: " + getObjectId ());
824824 }
825825
826+ final File processedTrackFile = getLocationOfProcessedTrack (true );
827+ final File processedTrackDir = processedTrackFile .getParentFile ();
826828 File targetFile = expData .getFile ();
827829 if (needsGzip () && !isGzipped ())
828830 {
829831 //need to gzip and tabix index:
830- final File finalLocation = getLocationOfProcessedTrack (true );
831- if (finalLocation .exists () && !SequencePipelineService .get ().hasMinLineCount (finalLocation , 1 ))
832+ if (processedTrackFile .exists () && !SequencePipelineService .get ().hasMinLineCount (processedTrackFile , 1 ))
832833 {
833834 log .info ("File exists but is zero-length, deleting and re-processing:" );
834835 forceReprocess = true ;
835836 }
836837
837- File idx = new File (finalLocation .getPath () + ".tbi" );
838- if (finalLocation .exists () && forceReprocess && !targetFile .equals (finalLocation ))
838+ File idx = new File (processedTrackFile .getPath () + ".tbi" );
839+ if (processedTrackFile .exists () && forceReprocess && !targetFile .equals (processedTrackFile ))
839840 {
840- finalLocation .delete ();
841+ processedTrackFile .delete ();
841842 if (idx .exists ())
842843 {
843844 idx .delete ();
844845 }
845846 }
846847
847- if (!finalLocation .exists ())
848+ if (!processedTrackFile .exists ())
848849 {
849850 if (throwIfNotPrepared )
850851 {
@@ -858,10 +859,10 @@ public File prepareResource(User u, Logger log, boolean throwIfNotPrepared, bool
858859
859860 try
860861 {
861- if (!targetFile .getParentFile ().equals (finalLocation .getParentFile ()))
862+ if (!targetFile .getParentFile ().equals (processedTrackFile .getParentFile ()))
862863 {
863864 log .debug ("Creating local copy of: " + targetFile .getPath ());
864- File local = new File ( finalLocation .getParentFile (), targetFile .getName ());
865+ File local = FileUtil . appendName ( processedTrackFile .getParentFile (), targetFile .getName ());
865866 if (local .exists ())
866867 {
867868 local .delete ();
@@ -872,15 +873,15 @@ public File prepareResource(User u, Logger log, boolean throwIfNotPrepared, bool
872873 }
873874
874875 File bgZipped = SequenceAnalysisService .get ().bgzipFile (targetFile , log );
875- FileUtils .moveFile (bgZipped , finalLocation );
876+ FileUtils .moveFile (bgZipped , processedTrackFile );
876877 }
877878 catch (IOException e )
878879 {
879880 throw new PipelineJobException (e );
880881 }
881882 }
882883
883- targetFile = finalLocation ;
884+ targetFile = processedTrackFile ;
884885 }
885886
886887 // Ensure index check runs even if file was already gzipped:
@@ -892,7 +893,7 @@ public File prepareResource(User u, Logger log, boolean throwIfNotPrepared, bool
892893
893894 if (doIndex ())
894895 {
895- File trixDir = new File ( targetFile . getParentFile () , "trix" );
896+ File trixDir = FileUtil . appendName ( processedTrackDir , "trix" );
896897 if (forceReprocess && trixDir .exists ())
897898 {
898899 try
@@ -923,7 +924,7 @@ public File prepareResource(User u, Logger log, boolean throwIfNotPrepared, bool
923924
924925 File exe = JBrowseManager .get ().getJbrowseCli ();
925926 SimpleScriptWrapper wrapper = new SimpleScriptWrapper (log );
926- wrapper .setWorkingDir (targetFile . getParentFile () );
927+ wrapper .setWorkingDir (processedTrackDir );
927928 wrapper .setThrowNonZeroExits (true );
928929
929930 wrapper .execute (Arrays .asList (exe .getPath (), "text-index" , "--force" , "--quiet" , "--attributes" , StringUtils .join (attributes , "," ), "--prefixSize" , "5" , "--file" , targetFile .getPath ()));
@@ -1056,7 +1057,7 @@ private boolean doesLuceneIndexExist()
10561057 }
10571058
10581059 // NOTE: is this the best file to test?
1059- luceneDir = new File (luceneDir , "write.lock" );
1060+ luceneDir = FileUtil . appendName (luceneDir , "write.lock" );
10601061 return luceneDir .exists ();
10611062 }
10621063
@@ -1162,7 +1163,7 @@ public File getLocationOfProcessedTrack(boolean createDir)
11621163 trackDir .mkdirs ();
11631164 }
11641165
1165- return new File (trackDir , FileUtil .makeLegalName (getSourceFileName ()).replaceAll (" " , "_" ) + (needsGzip () && !isGzipped () ? ".gz" : "" ));
1166+ return FileUtil . appendName (trackDir , FileUtil .makeLegalName (getSourceFileName ()).replaceAll (" " , "_" ) + (needsGzip () && !isGzipped () ? ".gz" : "" ));
11661167 }
11671168
11681169 protected String getSourceFileName ()
@@ -1184,8 +1185,8 @@ public File getExpectedLocationOfIndexFile(String extension, boolean throwIfNotF
11841185 return null ;
11851186 }
11861187
1187- File ret = new File (basedir .getParentFile (), "trix" );
1188- ret = new File (ret , basedir .getName () + extension );
1188+ File ret = FileUtil . appendName (basedir .getParentFile (), "trix" );
1189+ ret = FileUtil . appendName (ret , basedir .getName () + extension );
11891190
11901191 if (throwIfNotFound && !ret .exists ())
11911192 {
@@ -1434,7 +1435,7 @@ public File getExpectedLocationOfLuceneIndex(boolean throwIfNotFound)
14341435 return null ;
14351436 }
14361437
1437- File ret = new File (basedir .getParentFile (), "lucene" );
1438+ File ret = FileUtil . appendName (basedir .getParentFile (), "lucene" );
14381439 if (throwIfNotFound && !ret .exists ())
14391440 {
14401441 throw new IllegalStateException ("Expected search index not found: " + ret .getPath ());
0 commit comments