Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
return null;
}

Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, form.getAlleleNames());
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheAnalyses(getViewContext(), protocol, form.getAlleleNames());
resultProperties.put("runsCreated", ret.first);
resultProperties.put("runsDeleted", ret.second);
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public ApiResponse execute(CacheAnalysesForm form, BindException errors)
return null;
}

Pair<List<Integer>, List<Integer>> ret = GenotypeAssaysManager.get().cacheHaplotypes(getViewContext(), protocol, new JSONArray(form.getJson()));
Pair<List<Long>, List<Long>> ret = GenotypeAssaysManager.get().cacheHaplotypes(getViewContext(), protocol, new JSONArray(form.getJson()));
resultProperties.put("runsCreated", ret.first);
resultProperties.put("runsDeleted", ret.second);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.labkey.api.assay.AssayProvider;
import org.labkey.api.assay.AssayService;
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.api.collections.IntHashMap;
import org.labkey.api.collections.IntHashSet;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.CompareType;
import org.labkey.api.data.Container;
Expand Down Expand Up @@ -88,11 +90,11 @@ public static GenotypeAssaysManager get()
}


public Pair<List<Integer>, List<Integer>> cacheAnalyses(final ViewContext ctx, final ExpProtocol protocol, String[] pks) throws IllegalArgumentException
public Pair<List<Long>, List<Long>> cacheAnalyses(final ViewContext ctx, final ExpProtocol protocol, String[] pks) throws IllegalArgumentException
{
final User u = ctx.getUser();
final List<Integer> runsCreated = new ArrayList<>();
final List<Integer> runsDeleted = new ArrayList<>();
final List<Long> runsCreated = new ArrayList<>();
final List<Long> runsDeleted = new ArrayList<>();

try (DbScope.Transaction transaction = DbScope.getLabKeyScope().ensureTransaction())
{
Expand All @@ -118,8 +120,8 @@ public Pair<List<Integer>, List<Integer>> cacheAnalyses(final ViewContext ctx, f
AssayProtocolSchema schema = ap.createProtocolSchema(u, ctx.getContainer(), protocol, null);
final TableInfo assayDataTable = schema.getTable(AssayProtocolSchema.DATA_TABLE_NAME);

final Map<Integer, List<Map<String, Object>>> rowHash = new HashMap<>();
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new HashMap<>();
final Map<Integer, List<Map<String, Object>>> rowHash = new IntHashMap<>();
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new IntHashMap<>();

TableSelector tsAlignments = new TableSelector(tableAlignments, cols.values(), new SimpleFilter(FieldKey.fromString("key"), Arrays.asList(pks), CompareType.IN), null);
tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
Expand All @@ -139,7 +141,7 @@ public void exec(ResultSet object) throws SQLException
filter.addCondition(FieldKey.fromString("Run/assayType"), SBT_LINEAGE_ASSAY_TYPE);

TableSelector ts = new TableSelector(assayDataTable, PageFlowUtil.set("RowId"), filter, null);
Set<Integer> existing = new HashSet<>(ts.getArrayList(Integer.class));
Set<Integer> existing = new IntHashSet(ts.getArrayList(Integer.class));
if (!existing.isEmpty())
{
Set<Integer> toDelete = toDeleteByAnalysis.containsKey(analysisId) ? toDeleteByAnalysis.get(analysisId) : new HashSet<Integer>();
Expand Down Expand Up @@ -178,11 +180,11 @@ public void exec(ResultSet object) throws SQLException
}
}

public Pair<List<Integer>, List<Integer>> cacheHaplotypes(final ViewContext ctx, final ExpProtocol protocol, JSONArray data) throws IllegalArgumentException
public Pair<List<Long>, List<Long>> cacheHaplotypes(final ViewContext ctx, final ExpProtocol protocol, JSONArray data) throws IllegalArgumentException
{
final User u = ctx.getUser();
final List<Integer> runsCreated = new ArrayList<>();
final List<Integer> runsDeleted = new ArrayList<>();
final List<Long> runsCreated = new ArrayList<>();
final List<Long> runsDeleted = new ArrayList<>();

//next identify a build up the results
TableInfo tableAnalyses = QueryService.get().getUserSchema(u, ctx.getContainer(), SEQUENCEANALYSIS_SCHEMA).getTable("sequence_analyses");
Expand All @@ -196,8 +198,8 @@ public Pair<List<Integer>, List<Integer>> cacheHaplotypes(final ViewContext ctx,
fieldKeys.add(FieldKey.fromString("readset/subjectid"));
fieldKeys.add(FieldKey.fromString("readset/sampledate"));

Set<Integer> analysisIds = new HashSet<>();
final Map<Integer, List<JSONObject>> haploMap = new HashMap<>();
Set<Integer> analysisIds = new IntHashSet();
final Map<Integer, List<JSONObject>> haploMap = new IntHashMap<>();
for (JSONObject row : JsonUtil.toJSONObjectList(data))
{
Integer analysisId = row.getInt("analysisId");
Expand All @@ -217,8 +219,8 @@ public Pair<List<Integer>, List<Integer>> cacheHaplotypes(final ViewContext ctx,
AssayProtocolSchema schema = ap.createProtocolSchema(u, ctx.getContainer(), protocol, null);
final TableInfo assayDataTable = schema.getTable(AssayProtocolSchema.DATA_TABLE_NAME);

final Map<Integer, List<Map<String, Object>>> rowHash = new HashMap<>();
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new HashMap<>();
final Map<Integer, List<Map<String, Object>>> rowHash = new IntHashMap<>();
final Map<Integer, Set<Integer>> toDeleteByAnalysis = new IntHashMap<>();

TableSelector tsAlignments = new TableSelector(tableAnalyses, cols.values(), new SimpleFilter(FieldKey.fromString("rowid"), analysisIds, CompareType.IN), null);
tsAlignments.forEach(new Selector.ForEachBlock<ResultSet>()
Expand All @@ -244,10 +246,10 @@ public void exec(ResultSet object) throws SQLException
filter.addCondition(FieldKey.fromString("Run/assayType"), HAPLOTYPE_ASSAY_TYPE);

TableSelector ts = new TableSelector(assayDataTable, PageFlowUtil.set("RowId"), filter, null);
Set<Integer> existing = new HashSet<>(ts.getArrayList(Integer.class));
Set<Integer> existing = new IntHashSet(ts.getArrayList(Integer.class));
if (!existing.isEmpty())
{
Set<Integer> toDelete = toDeleteByAnalysis.containsKey(analysisId) ? toDeleteByAnalysis.get(analysisId) : new HashSet<>();
Set<Integer> toDelete = toDeleteByAnalysis.containsKey(analysisId) ? toDeleteByAnalysis.get(analysisId) : new IntHashSet();
toDelete.addAll(existing);
toDeleteByAnalysis.put(analysisId, toDelete);
}
Expand Down Expand Up @@ -288,7 +290,7 @@ public void exec(ResultSet object) throws SQLException
return Pair.of(runsCreated, runsDeleted);
}

private void processSet(String assayType, Map<Integer, List<Map<String, Object>>> rowHash, TableInfo assayDataTable, User u, ViewContext ctx, Map<Integer, Set<Integer>> toDeleteByAnalysis, AssayProvider ap, ExpProtocol protocol, List<Integer> runsCreated)
private void processSet(String assayType, Map<Integer, List<Map<String, Object>>> rowHash, TableInfo assayDataTable, User u, ViewContext ctx, Map<Integer, Set<Integer>> toDeleteByAnalysis, AssayProvider ap, ExpProtocol protocol, List<Long> runsCreated)
{
for (Integer analysisId : rowHash.keySet())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.List;
import java.util.Map;

import static org.labkey.api.exp.api.ExperimentService.asInteger;

/**
* Created with IntelliJ IDEA.
* User: bimber
Expand Down Expand Up @@ -134,7 +136,7 @@ protected List<Map<String, Object>> calculatePositivity(List<Map<String, Object>

if (TYPE.NEG.getText().equals(row.get(CATEGORY_FIELD)))
{
Integer spots = (Integer)row.get(SPOTS_FIELD);
Integer spots = asInteger(row.get(SPOTS_FIELD));
List<Double> negCtls = negWellMap.get(negCtlKey);
if (negCtls == null)
negCtls = new ArrayList<Double>();
Expand Down Expand Up @@ -188,8 +190,8 @@ protected List<Map<String, Object>> calculatePositivity(List<Map<String, Object>
int rowIdx = 0;
for (Map<String, Object> row : rowSet)
{
totalSpots += (Integer)row.get(SPOTS_FIELD);
allSpots[rowIdx] = (Integer)row.get(SPOTS_FIELD);
totalSpots += asInteger(row.get(SPOTS_FIELD));
allSpots[rowIdx] = asInteger(row.get(SPOTS_FIELD));
rowIdx++;
}
Double avgSpots = totalSpots / rowSet.size();
Expand Down Expand Up @@ -262,7 +264,7 @@ protected List<Map<String, Object>> calculatePositivity(List<Map<String, Object>
row.put(QCFLAG_FIELD, StringUtils.join(qcflags, "\n"));

//subtract background
Integer spots = (Integer)row.get(SPOTS_FIELD);
Integer spots = asInteger(row.get(SPOTS_FIELD));
Double adj = spots - negCtlSummary.getMean();
List<String> comments = new ArrayList<String>();
if (row.get("comment") != null)
Expand Down
6 changes: 4 additions & 2 deletions mGAP/src/org/labkey/mgap/mGAPController.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import static org.labkey.api.exp.api.ExperimentService.asInteger;


public class mGAPController extends SpringActionController
{
Expand Down Expand Up @@ -413,7 +415,7 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws
User u;
if (map.get("userId") != null)
{
Integer userId = (Integer) map.get("userId");
Integer userId = asInteger(map.get("userId"));
u = UserManager.getUser(userId);
existingUsersGivenAccess.add(u);
}
Expand Down Expand Up @@ -556,7 +558,7 @@ else if (!rowContainer.hasPermission(u, ReadPermission.class))

private static SequenceOutputFile getOutputFile(Map<String, Object> row, ReleaseForm form, Errors errors)
{
SequenceOutputFile so = SequenceOutputFile.getForId((Integer) row.get("vcfId"));
SequenceOutputFile so = SequenceOutputFile.getForId(asInteger(row.get("vcfId")));
if (so == null)
{
errors.reject(ERROR_MSG, "Unknown VCF file ID: " + form.getReleaseId());
Expand Down
4 changes: 3 additions & 1 deletion mcc/src/org/labkey/mcc/MccController.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static org.labkey.api.exp.api.ExperimentService.asInteger;

public class MccController extends SpringActionController
{
private static final DefaultActionResolver _actionResolver = new DefaultActionResolver(MccController.class);
Expand Down Expand Up @@ -356,7 +358,7 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws
User u;
if (map.get("userId") != null)
{
Integer userId = (Integer)map.get("userId");
Integer userId = asInteger(map.get("userId"));
u = UserManager.getUser(userId);
existingUsersGivenAccess.add(u);
}
Expand Down
4 changes: 3 additions & 1 deletion mcc/src/org/labkey/mcc/query/TriggerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import static org.labkey.api.exp.api.ExperimentService.asInteger;

/**
* Created by bimber
*/
Expand Down Expand Up @@ -135,7 +137,7 @@ public void ensureReviewRecordsCreated(String objectId, String status, @Nullable
}

Map<String, Object> row = records.get(0);
if (score != (Integer)row.get("preliminaryScore"))
if (score != asInteger(row.get("preliminaryScore")))
{
row.put("preliminaryScore", score);
row.put("modified", new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.jetbrains.annotations.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
import org.labkey.api.collections.IntHashMap;
import org.labkey.api.collections.StringHashMap;
import org.labkey.api.data.Container;
import org.labkey.api.jbrowse.JBrowseService;
import org.labkey.api.module.Module;
Expand Down Expand Up @@ -49,7 +51,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -188,7 +189,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
ctx.getLogger().info(groupNames.getString(i));
}

Map<Integer, Integer> fileToGroupMap = new HashMap<>();
Map<Integer, Integer> fileToGroupMap = new IntHashMap<>();
JSONObject map = ctx.getParams().getJSONObject("fileToGroupMap");
for (String id : map.keySet())
{
Expand All @@ -201,7 +202,7 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c
String statisticalMethod = ctx.getParams().optString("statisticalMethod");

//build map of site rates
Map<String, Map<Integer, Map<Integer, List<Double>>>> rateMap = new HashMap<>();
Map<String, Map<Integer, Map<Integer, List<Double>>>> rateMap = new StringHashMap<>();

int i = 0;
for (SequenceOutputFile o : inputFiles)
Expand Down Expand Up @@ -268,12 +269,12 @@ public void processFilesRemote(List<SequenceOutputFile> inputFiles, JobContext c

if (!rateMap.containsKey(chr))
{
rateMap.put(chr, new HashMap<>());
rateMap.put(chr, new IntHashMap<>());
}

if (!rateMap.get(chr).containsKey(pos))
{
rateMap.get(chr).put(pos, new HashMap<>());
rateMap.get(chr).put(pos, new IntHashMap<>());
}

if (!rateMap.get(chr).get(pos).containsKey(groupNum))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ else if (getProvider().getParameterByName("siteReport") != null && getProvider()
@Override
public Output performAnalysisPerSampleLocal(AnalysisModel model, File inputBam, File referenceFasta, File outDir) throws PipelineJobException
{
Integer runId = SequenceAnalysisService.get().getExpRunIdForJob(getPipelineCtx().getJob(), true);
Long runId = SequenceAnalysisService.get().getExpRunIdForJob(getPipelineCtx().getJob(), true);

Set<SequenceOutputFile> toCreate = new HashSet<>();
SequenceOutputTracker sot = ((SequenceOutputTracker)getPipelineCtx().getJob());
Expand Down
Loading