Skip to content

Commit 184908d

Browse files
authored
Attempt to improve JBrowseTest (#92)
* Attempt to improve JBrowseTest
1 parent 7694ae5 commit 184908d

6 files changed

Lines changed: 50 additions & 42 deletions

File tree

SequenceAnalysis/src/org/labkey/sequenceanalysis/util/SequenceUtil.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -455,18 +455,7 @@ public static void sortROD(File input, Logger log, Integer startColumnIdx) throw
455455

456456
//replace the non-sorted output
457457
input.delete();
458-
if (isCompressed)
459-
{
460-
File compressed = SequenceUtil.bgzip(sorted, log);
461-
if (!compressed.equals(input))
462-
{
463-
FileUtils.moveFile(compressed, input);
464-
}
465-
}
466-
else
467-
{
468-
FileUtils.moveFile(sorted, input);
469-
}
458+
FileUtils.moveFile(sorted, input);
470459
sorted.delete();
471460
}
472461

jbrowse/resources/web/jbrowse/window/ModifyJsonConfigWindow.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ Ext4.define('JBrowse.window.ModifyJsonConfigWindow', {
8383
handler: function (gridBtn) {
8484
this.addAttribute('omitTrack', true, 'BOOLEAN');
8585
}
86+
},{
87+
text: 'Add to Text Search Index?',
88+
scope: this,
89+
handler: function (gridBtn) {
90+
this.addAttribute('includeInSearch', true, 'BOOLEAN');
91+
}
92+
},{
93+
text: 'Exclude from Text Search Index?',
94+
scope: this,
95+
handler: function (gridBtn) {
96+
this.addAttribute('excludeFromSearch', true, 'BOOLEAN');
97+
}
8698
},{
8799
text: 'Other',
88100
scope: this,

jbrowse/src/org/labkey/jbrowse/JBrowseMaintenanceTask.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.labkey.api.data.TableInfo;
1616
import org.labkey.api.data.TableSelector;
1717
import org.labkey.api.ldk.LDKService;
18-
import org.labkey.api.pipeline.PipelineJobException;
1918
import org.labkey.api.query.FieldKey;
2019
import org.labkey.api.security.User;
2120
import org.labkey.api.util.PageFlowUtil;
@@ -77,6 +76,24 @@ public void run(Logger log)
7776
//delete JSON in output dir not associated with DB record
7877
try
7978
{
79+
// TODO: ultimately remove this. This is related to the migration from JB1 to JB2
80+
TableInfo jsonFiles = JBrowseSchema.getInstance().getTable(JBrowseSchema.TABLE_JSONFILES);
81+
List<String> toDelete = new TableSelector(jsonFiles, PageFlowUtil.set("objectid"), new SimpleFilter(FieldKey.fromString("sequenceid"), null, CompareType.NONBLANK), null).getArrayList(String.class);
82+
if (!toDelete.isEmpty())
83+
{
84+
log.info("deleted " + toDelete.size() + " legacy NT JsonFile records");
85+
for (String key : toDelete)
86+
{
87+
Table.delete(jsonFiles, key);
88+
89+
int d = new SqlExecutor(JBrowseSchema.getInstance().getSchema()).execute(new SQLFragment("DELETE FROM " + JBrowseSchema.NAME + "." + JBrowseSchema.TABLE_DATABASE_MEMBERS + " WHERE jsonfile = ?", key));
90+
if (d > 0)
91+
{
92+
log.info("also deleted " + d + " orphan database member record(s) for: " + key);
93+
}
94+
}
95+
}
96+
8097
//delete sessions marked as temporary
8198
int sessionsDeleted = Table.delete(JBrowseSchema.getInstance().getTable(JBrowseSchema.TABLE_DATABASES), new SimpleFilter(FieldKey.fromString("temporary"), true));
8299
if (sessionsDeleted > 0)
@@ -92,9 +109,6 @@ public void run(Logger log)
92109
" WHERE " +
93110
//find JSONFiles not associated with a database_member record
94111
" (SELECT count(rowid) FROM " + JBrowseSchema.NAME + "." + JBrowseSchema.TABLE_DATABASE_MEMBERS + " d WHERE d.jsonfile = " + JBrowseSchema.TABLE_JSONFILES + ".objectid) = 0 AND " +
95-
//TODO: ultimately completely remove these
96-
//or library reference sequences
97-
" (SELECT count(rowid) FROM sequenceanalysis.reference_library_members d WHERE d.ref_nt_id = " + JBrowseSchema.TABLE_JSONFILES + ".sequenceid) = 0 AND " +
98112
//or library tracks
99113
" (SELECT count(rowid) FROM sequenceanalysis.reference_library_tracks d WHERE d.rowid = " + JBrowseSchema.TABLE_JSONFILES + ".trackid) = 0 AND " +
100114
//or outputfiles
@@ -105,11 +119,8 @@ public void run(Logger log)
105119
log.info("deleted " + deleted2 + " JSON files because they are not used by any sessions");
106120

107121
//second pass at orphan JSONFiles. Note: these might be referenced by a database_member record still.
108-
List<String> toDelete = new SqlSelector(JBrowseSchema.getInstance().getSchema(), new SQLFragment("SELECT objectid FROM " + JBrowseSchema.NAME + "." + JBrowseSchema.TABLE_JSONFILES +
122+
toDelete = new SqlSelector(JBrowseSchema.getInstance().getSchema(), new SQLFragment("SELECT objectid FROM " + JBrowseSchema.NAME + "." + JBrowseSchema.TABLE_JSONFILES +
109123
" WHERE " +
110-
//TODO: ultimately completely remove these
111-
//reference NT sequences
112-
" (" + JBrowseSchema.TABLE_JSONFILES + ".sequenceid IS NOT NULL AND (SELECT count(rowid) FROM sequenceanalysis.ref_nt_sequences d WHERE d.rowid = " + JBrowseSchema.TABLE_JSONFILES + ".sequenceid) = 0) OR " +
113124
//library tracks
114125
" ( " + JBrowseSchema.TABLE_JSONFILES + ".trackid IS NOT NULL AND (SELECT count(rowid) FROM sequenceanalysis.reference_library_tracks d WHERE d.rowid = " + JBrowseSchema.TABLE_JSONFILES + ".trackid) = 0) OR " +
115126
//outputfiles
@@ -119,7 +130,6 @@ public void run(Logger log)
119130
if (!toDelete.isEmpty())
120131
{
121132
log.info("deleting " + toDelete.size() + " JSON files because they reference non-existent tracks, sequences or outputfiles");
122-
TableInfo jsonFiles = JBrowseSchema.getInstance().getTable(JBrowseSchema.TABLE_JSONFILES);
123133
for (String key : toDelete)
124134
{
125135
Table.delete(jsonFiles, key);
@@ -141,7 +151,7 @@ public void run(Logger log)
141151
}
142152
}
143153

144-
private void processContainer(Container c, Logger log) throws IOException, PipelineJobException
154+
private void processContainer(Container c, Logger log) throws IOException
145155
{
146156
File jbrowseRoot = JBrowseManager.get().getBaseDir(c, false);
147157

@@ -202,9 +212,8 @@ private void processContainer(Container c, Logger log) throws IOException, Pipel
202212
File childDir = new File(jbrowseRoot, dir);
203213
if (childDir.exists())
204214
{
205-
//TODO: eventually delete these?
206-
//log.info("deleting legacy jbrowse " + dir + " dir: " + childDir.getPath());
207-
//FileUtils.deleteDirectory(childDir);
215+
log.info("deleting legacy jbrowse " + dir + " dir: " + childDir.getPath());
216+
FileUtils.deleteDirectory(childDir);
208217
}
209218
}
210219

jbrowse/src/org/labkey/jbrowse/model/DbBackedJsonFile.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ public File getLocationOfProcessedTrack(boolean createDir)
8585
return new File(trackDir, getSourceFileName());
8686
}
8787

88+
@Override
89+
public boolean needsProcessing()
90+
{
91+
return true;
92+
}
93+
8894
@Override
8995
public String getLabel()
9096
{

jbrowse/src/org/labkey/jbrowse/model/JsonFile.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,6 @@ public File getBaseDir()
175175

176176
private static final FileType _ft = new FileType(Arrays.asList(".bam", ".vcf"), ".vcf", FileType.gzSupportLevel.SUPPORT_GZ);
177177

178-
//NOTE: if the track file isnt parsed to JSON (VCF or BAM), then the file will be in getBaseDir()
179-
public boolean expectDataSubdirForTrack()
180-
{
181-
File f = getTrackFile();
182-
if (f == null)
183-
{
184-
throw new IllegalArgumentException("Unable to find file for JSONFile: " + _objectId);
185-
}
186-
187-
return !_ft.isType(f);
188-
}
189-
190178
public String getLabel()
191179
{
192180
if (_label == null)
@@ -408,8 +396,9 @@ public boolean doIndex()
408396
return false;
409397
}
410398

399+
// The intent of this is to index GFF/GTF files that are part of the primary genome, not ad hoc resources. These files can opt-in to indexing using
411400
//TODO: restore this once JB2 support GTF indexing: TRACK_TYPES.gtf.getFileType().isType(sourceFilename)
412-
boolean doIndex = TRACK_TYPES.gff.getFileType().isType(sourceFilename);
401+
boolean doIndex = TRACK_TYPES.gff.getFileType().isType(sourceFilename) && getTrackId() != null;
413402
JSONObject config = getExtraTrackConfig();
414403
if (config != null)
415404
{

jbrowse/test/src/org/labkey/test/tests/external/labModules/JBrowseTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.labkey.test.tests.external.labModules;
1717

18-
import org.apache.velocity.util.ArrayListWrapper;
1918
import org.junit.Assert;
2019
import org.junit.Test;
2120
import org.junit.experimental.categories.Category;
@@ -44,7 +43,6 @@
4443

4544
import java.io.File;
4645
import java.io.IOException;
47-
import java.util.ArrayList;
4846
import java.util.Arrays;
4947
import java.util.List;
5048
import java.util.Map;
@@ -121,6 +119,11 @@ private By getVariantWithinTrack(String trackId, String variantText, boolean wai
121119
{
122120
trackId = "trackRenderingContainer-linearGenomeView-" + trackId;
123121
Locator.XPathLocator l = Locator.tagWithAttributeContaining("div", "data-testid", trackId);
122+
if (waitFor)
123+
{
124+
waitForElement(l);
125+
}
126+
124127
l = l.append(Locator.xpath("//*[name()='text' and contains(text(), '" + variantText + "')]/..")).notHidden();
125128

126129
if (waitFor)
@@ -145,8 +148,8 @@ private void testMessageDisplay()
145148
private void waitForJBrowseToLoad()
146149
{
147150
waitForElementToDisappear(Locator.tagWithText("p", "Loading..."));
148-
waitForElement(Locator.tagWithClass("span", "MuiIconButton-label")); //this is the top-left icon
149-
waitForElement(Locator.tagWithClassContaining("span", "MuiTypography-root"), WAIT_FOR_PAGE); //this is the icon from the track label
151+
waitForElement(Locator.tagWithClass("span", "MuiIconButton-label").notHidden()); //this is the top-left icon
152+
waitForElement(Locator.tagWithClassContaining("span", "MuiTypography-root").notHidden(), WAIT_FOR_PAGE); //this is the icon from the track label
150153

151154
waitForElementToDisappear(Locator.tagWithText("div", "Loading...")); //track data
152155
}

0 commit comments

Comments
 (0)