Skip to content

Commit 48815be

Browse files
committed
Workaround for inconsistent jbrowse generate-file behavior
1 parent 4c185e0 commit 48815be

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

jbrowse/src/org/labkey/jbrowse/JBrowseRoot.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,9 @@ else if (f.getTrackId() != null)
674674

675675
//even through we're loading the raw data based on urlTemplate, make a symlink from this location into our DB so generate-names.pl works properly
676676
File sourceFile = f.expectDataSubdirForTrack() ? new File(f.getTrackRootDir(), "tracks/track-" + f.getTrackId()) : f.getTrackRootDir();
677-
File targetFile = new File(outDir, "tracks/track-" + f.getTrackId());
677+
sourceFile = identifyValidParentDir(sourceFile);
678678

679+
File targetFile = new File(outDir, "tracks/track-" + f.getTrackId());
679680
createSymlink(targetFile, sourceFile);
680681
}
681682
else if (f.getOutputFile() != null)
@@ -1019,6 +1020,21 @@ else if (f.getOutputFile() != null)
10191020
}
10201021
}
10211022

1023+
// For some reason the location of the subdir is still not consistent. We're going ot migrate to jbrowse2
1024+
// and stop using the perl scripts, so while this is a hack, leave in place for now.
1025+
private File identifyValidParentDir(File sourceDir)
1026+
{
1027+
int i = 1;
1028+
File target = new File(sourceDir, "trackList.json");
1029+
while (i < 3 && !target.exists())
1030+
{
1031+
i++;
1032+
target = new File(target.getParentFile().getParentFile(), "trackList.json");
1033+
}
1034+
1035+
return target == null ? sourceDir : target.getParentFile();
1036+
}
1037+
10221038
private boolean shouldCreateOwnIndex(String databaseId) throws PipelineJobException
10231039
{
10241040
TableSelector ts = new TableSelector(JBrowseSchema.getInstance().getTable(JBrowseSchema.TABLE_DATABASES), PageFlowUtil.set("libraryId", "createOwnIndex", "primaryDb"), new SimpleFilter(FieldKey.fromString("objectid"), databaseId), null);
@@ -1278,7 +1294,7 @@ private void createSymlink(File targetFile, File sourceFile) throws IOException
12781294

12791295
if (!sourceFile.exists())
12801296
{
1281-
getLogger().error("unable to find file: " + sourceFile.getPath());
1297+
getLogger().error("unable to find file: " + sourceFile.getPath(), new Exception());
12821298
}
12831299

12841300
if (targetFile.exists())

0 commit comments

Comments
 (0)