Skip to content

Commit 1604ef3

Browse files
committed
Cleanup JBrowseMaintenanceTask code
1 parent 639044c commit 1604ef3

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727

2828
import java.io.File;
2929
import java.io.IOException;
30-
import java.util.ArrayList;
3130
import java.util.Arrays;
3231
import java.util.HashSet;
3332
import java.util.List;
33+
import java.util.Map;
3434
import java.util.Set;
35+
import java.util.function.Function;
36+
import java.util.stream.Collectors;
3537

3638
/**
3739
* User: bimber
@@ -165,7 +167,7 @@ private void processContainer(Container c, Logger log) throws IOException
165167
filter.addCondition(FieldKey.fromString("sequenceid"), null, CompareType.ISBLANK);
166168

167169
TableSelector ts = new TableSelector(tableJsonFiles, filter, null);
168-
List<JsonFile> rows = new ArrayList<>(ts.getArrayList(JsonFile.class));
170+
Map<String, JsonFile> rowMap = ts.getArrayList(JsonFile.class).stream().collect(Collectors.toMap(JsonFile::getObjectId, Function.identity()));
169171

170172
// Also check for genomes from this container, and any additional JsonFiles they may have:
171173
TableInfo tableGenomes = DbSchema.get(JBrowseManager.SEQUENCE_ANALYSIS, DbSchemaType.Module).getTable("reference_libraries");
@@ -184,6 +186,7 @@ private void processContainer(Container c, Logger log) throws IOException
184186
JBrowseSession session = JBrowseSession.getGenericGenomeSession(genomeId);
185187
for (JsonFile json : session.getJsonFiles(u, true))
186188
{
189+
rowMap.put(json.getObjectId(), json);
187190
expectedDirs.add(json.getBaseDir());
188191
if (!json.getBaseDir().exists())
189192
{
@@ -197,7 +200,7 @@ private void processContainer(Container c, Logger log) throws IOException
197200
if (jbrowseRoot != null && jbrowseRoot.exists())
198201
{
199202
log.info("processing container: " + c.getPath());
200-
for (JsonFile json : rows)
203+
for (JsonFile json : rowMap.values())
201204
{
202205
if (json.getBaseDir() != null)
203206
{
@@ -248,7 +251,7 @@ private void processContainer(Container c, Logger log) throws IOException
248251
}
249252
}
250253

251-
for (JsonFile j : rows)
254+
for (JsonFile j : rowMap.values())
252255
{
253256
if (j.needsProcessing())
254257
{

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,17 +657,17 @@ public File prepareResource(Logger log, boolean throwIfNotPrepared, boolean forc
657657
if (needsGzip() && !isGzipped())
658658
{
659659
//need to gzip and tabix index:
660-
File finalLocation = getLocationOfProcessedTrack(true);
660+
final File finalLocation = getLocationOfProcessedTrack(true);
661661
if (finalLocation.exists() && !SequencePipelineService.get().hasMinLineCount(finalLocation, 1))
662662
{
663663
log.info("File exists but is zero-length, deleting and re-processing:");
664664
forceReprocess = true;
665665
}
666666

667+
File idx = new File(finalLocation.getPath() + ".tbi");
667668
if (finalLocation.exists() && forceReprocess && !targetFile.equals(finalLocation))
668669
{
669670
finalLocation.delete();
670-
File idx = new File(finalLocation.getPath() + ".tbi");
671671
if (idx.exists())
672672
{
673673
idx.delete();
@@ -710,7 +710,6 @@ public File prepareResource(Logger log, boolean throwIfNotPrepared, boolean forc
710710
}
711711
}
712712

713-
File idx = new File(finalLocation.getPath() + ".tbi");
714713
if (forceReprocess || !idx.exists())
715714
{
716715
if (throwIfNotPrepared)

0 commit comments

Comments
 (0)