|
32 | 32 | import org.labkey.api.query.FieldKey; |
33 | 33 | import org.labkey.api.query.QueryService; |
34 | 34 | import org.labkey.api.query.UserSchema; |
| 35 | +import org.labkey.api.reader.Readers; |
35 | 36 | import org.labkey.api.security.User; |
36 | 37 | import org.labkey.api.security.permissions.ReadPermission; |
37 | 38 | import org.labkey.api.sequenceanalysis.SequenceAnalysisService; |
|
46 | 47 | import org.labkey.api.util.PageFlowUtil; |
47 | 48 | import org.labkey.api.util.Path; |
48 | 49 | import org.labkey.api.view.UnauthorizedException; |
| 50 | +import org.labkey.api.writer.PrintWriters; |
49 | 51 | import org.labkey.jbrowse.JBrowseManager; |
50 | 52 | import org.labkey.jbrowse.JBrowseSchema; |
51 | 53 | import org.labkey.sequenceanalysis.run.util.TabixRunner; |
52 | 54 |
|
53 | 55 | import javax.annotation.Nullable; |
| 56 | +import java.io.BufferedReader; |
54 | 57 | import java.io.File; |
55 | 58 | import java.io.IOException; |
| 59 | +import java.io.PrintWriter; |
56 | 60 | import java.sql.SQLException; |
57 | 61 | import java.util.Arrays; |
58 | 62 | import java.util.Collections; |
@@ -836,6 +840,40 @@ public File prepareResource(Logger log, boolean throwIfNotPrepared, boolean forc |
836 | 840 | { |
837 | 841 | throw new PipelineJobException("Unable to find expected index file: " + ixx.getPath()); |
838 | 842 | } |
| 843 | + |
| 844 | + // See here: https://github.com/GMOD/jbrowse-components/issues/2344 |
| 845 | + // for background. this hackery is needed to ensure the trackId listed in the ix matches the GUID, not the filename: |
| 846 | + log.info("Updating trackId in trix ix file"); |
| 847 | + File ix = getExpectedLocationOfIndexFile(".ix", false); |
| 848 | + if (!ix.exists()) |
| 849 | + { |
| 850 | + throw new PipelineJobException("Unable to find file: " + ix.getPath()); |
| 851 | + } |
| 852 | + |
| 853 | + File ixCopy = new File(ix.getPath() + ".tmp"); |
| 854 | + try (PrintWriter writer = PrintWriters.getPrintWriter(ixCopy); BufferedReader reader = Readers.getReader(ix)) |
| 855 | + { |
| 856 | + String line; |
| 857 | + while ((line = reader.readLine()) != null) |
| 858 | + { |
| 859 | + line = line.replaceAll("\"" + targetFile.getName() + "\"", "\"" + getObjectId() + "\""); |
| 860 | + writer.println(line); |
| 861 | + } |
| 862 | + } |
| 863 | + catch (IOException e) |
| 864 | + { |
| 865 | + throw new PipelineJobException(e); |
| 866 | + } |
| 867 | + |
| 868 | + try |
| 869 | + { |
| 870 | + ix.delete(); |
| 871 | + FileUtils.moveFile(ixCopy, ix); |
| 872 | + } |
| 873 | + catch (IOException e) |
| 874 | + { |
| 875 | + throw new PipelineJobException(e); |
| 876 | + } |
839 | 877 | } |
840 | 878 | } |
841 | 879 |
|
|
0 commit comments