|
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; |
@@ -497,7 +501,7 @@ private JSONObject getVcfTrack(Logger log, ExpData targetFile, ReferenceGenome r |
497 | 501 | { |
498 | 502 | JSONObject ret = new JSONObject(); |
499 | 503 | ret.put("type", getTrackType()); |
500 | | - ret.put("trackId", getObjectId()); |
| 504 | + ret.put("trackId", getJsonTrackId()); |
501 | 505 | ret.put("name", getLabel()); |
502 | 506 | ret.put("assemblyNames", new JSONArray(){{ |
503 | 507 | put(JBrowseSession.getAssemblyName(rg)); |
@@ -527,7 +531,7 @@ private JSONObject getVcfTrack(Logger log, ExpData targetFile, ReferenceGenome r |
527 | 531 | ret.put("displays", new JSONArray(){{ |
528 | 532 | put(new JSONObject(){{ |
529 | 533 | put("type", "ExtendedVariantDisplay"); |
530 | | - put("displayId", getObjectId() + "-ExtendedVariantDisplay"); |
| 534 | + put("displayId", getJsonTrackId() + "-ExtendedVariantDisplay"); |
531 | 535 | put("maxDisplayedBpPerPx", 2000); |
532 | 536 | put("mouseover", "jexl:'Position: ' + formatWithCommas(get(feature,'POS'))"); |
533 | 537 | put("renderer", new JSONObject(){{ |
@@ -559,11 +563,17 @@ public boolean matchesTrackSelector(List<String> toTest) |
559 | 563 | return toTest.contains(getObjectId()) || toTest.contains(getLabel()); |
560 | 564 | } |
561 | 565 |
|
| 566 | + public String getJsonTrackId() |
| 567 | + { |
| 568 | + final File finalLocation = getLocationOfProcessedTrack(false); |
| 569 | + return finalLocation == null ? null : finalLocation.getName(); |
| 570 | + } |
| 571 | + |
562 | 572 | private JSONObject getBamTrack(Logger log, ExpData targetFile, ReferenceGenome rg) |
563 | 573 | { |
564 | 574 | JSONObject ret = new JSONObject(); |
565 | 575 | ret.put("type", getTrackType()); |
566 | | - ret.put("trackId", getObjectId()); |
| 576 | + ret.put("trackId", getJsonTrackId()); |
567 | 577 | ret.put("name", getLabel()); |
568 | 578 | ret.put("category", new JSONArray(){{ |
569 | 579 | put(getCategory()); |
@@ -647,7 +657,7 @@ private JSONObject getTabixTrack(Logger log, ExpData targetFile, ReferenceGenome |
647 | 657 | { |
648 | 658 | JSONObject ret = new JSONObject(); |
649 | 659 | ret.put("type", getTrackType()); |
650 | | - ret.put("trackId", getObjectId()); |
| 660 | + ret.put("trackId", getJsonTrackId()); |
651 | 661 | ret.put("name", getLabel()); |
652 | 662 | ret.put("category", new JSONArray(){{ |
653 | 663 | put(getCategory()); |
@@ -829,13 +839,20 @@ public File prepareResource(Logger log, boolean throwIfNotPrepared, boolean forc |
829 | 839 | wrapper.setWorkingDir(targetFile.getParentFile()); |
830 | 840 | wrapper.setThrowNonZeroExits(true); |
831 | 841 |
|
832 | | - //TODO: eventually remove this. see: https://github.com/GMOD/jbrowse-components/issues/2354#issuecomment-926320747 |
833 | | - wrapper.addToEnvironment("DEBUG", "*"); |
834 | 842 | wrapper.execute(Arrays.asList(exe.getPath(), "text-index", "--force", "--quiet", "--attributes", StringUtils.join(attributes, ","), "--prefixSize", "5", "--file", targetFile.getPath())); |
835 | 843 | if (!ixx.exists()) |
836 | 844 | { |
837 | 845 | throw new PipelineJobException("Unable to find expected index file: " + ixx.getPath()); |
838 | 846 | } |
| 847 | + |
| 848 | + // See here: https://github.com/GMOD/jbrowse-components/issues/2344 |
| 849 | + // for background. this hackery is needed to ensure the trackId listed in the ix matches the GUID, not the filename: |
| 850 | + log.info("Updating trackId in trix ix file"); |
| 851 | + File ix = getExpectedLocationOfIndexFile(".ix", false); |
| 852 | + if (!ix.exists()) |
| 853 | + { |
| 854 | + throw new PipelineJobException("Unable to find file: " + ix.getPath()); |
| 855 | + } |
839 | 856 | } |
840 | 857 | } |
841 | 858 |
|
|
0 commit comments