public static Map<String, VariableSet> getVariableSetMap(Study study) { Map<String, VariableSet> variableSetMap = new HashMap<>(); List<VariableSet> variableSets = study.getVariableSets(); if (variableSets != null) { for (VariableSet variableSet : variableSets) { variableSetMap.put(variableSet.getId(), variableSet); } } return variableSetMap; }
public CatalogIndividualToSolrIndividualConverter(Study study) { this.study = study; this.variableMap = new HashMap<>(); if (this.study.getVariableSets() != null) { this.study.getVariableSets().forEach(variableSet -> { try { this.variableMap.put(variableSet.getId(), AnnotationUtils.getVariableMap(variableSet)); } catch (CatalogDBException e) { logger.warn("Could not parse variableSet {}: {}", variableSet.getId(), e.getMessage(), e); } }); } }
public CatalogFamilyToSolrFamilyConverter(Study study) { this.study = study; this.variableMap = new HashMap<>(); if (this.study.getVariableSets() != null) { this.study.getVariableSets().forEach(variableSet -> { try { this.variableMap.put(variableSet.getId(), AnnotationUtils.getVariableMap(variableSet)); } catch (CatalogDBException e) { logger.warn("Could not parse variableSet {}: {}", variableSet.getId(), e.getMessage(), e); } }); } }
public CatalogFileToSolrFileConverter(Study study) { this.study = study; this.variableMap = new HashMap<>(); if (this.study.getVariableSets() != null) { this.study.getVariableSets().forEach(variableSet -> { try { this.variableMap.put(variableSet.getId(), AnnotationUtils.getVariableMap(variableSet)); } catch (CatalogDBException e) { logger.warn("Could not parse variableSet {}: {}", variableSet.getId(), e.getMessage(), e); } }); } }
public CatalogSampleToSolrSampleConverter(Study study) { this.study = study; this.variableMap = new HashMap<>(); if (this.study.getVariableSets() != null) { this.study.getVariableSets().forEach(variableSet -> { try { this.variableMap.put(variableSet.getId(), AnnotationUtils.getVariableMap(variableSet)); } catch (CatalogDBException e) { logger.warn("Could not parse variableSet {}: {}", variableSet.getId(), e.getMessage(), e); } }); } }
public CatalogCohortToSolrCohortConverter(Study study) { this.study = study; this.variableMap = new HashMap<>(); if (this.study.getVariableSets() != null) { this.study.getVariableSets().forEach(variableSet -> { try { this.variableMap.put(variableSet.getId(), AnnotationUtils.getVariableMap(variableSet)); } catch (CatalogDBException e) { logger.warn("Could not parse variableSet {}: {}", variableSet.getId(), e.getMessage(), e); } }); } }
@Override public QueryResult<VariableSet> getVariableSet(long variableSetId, QueryOptions options, String user) throws CatalogDBException, CatalogAuthorizationException { long startTime = startQuery(); Bson query = new Document("variableSets", new Document("$elemMatch", new Document(PRIVATE_UID, variableSetId))); QueryOptions qOptions = new QueryOptions(QueryOptions.INCLUDE, "variableSets.$,_ownerId,groups,_acl"); QueryResult<Document> studyQueryResult = studyCollection.find(query, qOptions); if (studyQueryResult.getNumResults() == 0) { throw new CatalogDBException("Variable set not found."); } if (!checkCanViewStudy(studyQueryResult.first(), user)) { throw CatalogAuthorizationException.deny(user, "view", "VariableSet", variableSetId, ""); } Study study = studyConverter.convertToDataModelType(studyQueryResult.first()); if (study.getVariableSets() == null || study.getVariableSets().isEmpty()) { throw new CatalogDBException("Variable set not found."); } // Check if it is confidential if (study.getVariableSets().get(0).isConfidential()) { if (!checkStudyPermission(studyQueryResult.first(), user, StudyAclEntry.StudyPermissions.CONFIDENTIAL_VARIABLE_SET_ACCESS.toString())) { throw CatalogAuthorizationException.deny(user, StudyAclEntry.StudyPermissions.CONFIDENTIAL_VARIABLE_SET_ACCESS.toString(), "VariableSet", variableSetId, ""); } } return endQuery("", startTime, study.getVariableSets()); }
List<VariableSet> variableSetList = studyQueryResult.first().getVariableSets(); if (variableSetList == null || variableSetList.isEmpty()) { throw new CatalogException("Impossible annotating variables from a study without VariableSets defined");
List<VariableSet> variableSets = parseObjects(queryResult, Study.class).stream().map(study -> study.getVariableSets().get(0)) .collect(Collectors.toList());
@Override public QueryResult<VariableSet> getVariableSet(long variableSetId, QueryOptions options) throws CatalogDBException { long startTime = startQuery(); Query query = new Query(QueryParams.VARIABLE_SET_UID.key(), variableSetId); Bson projection = Projections.elemMatch("variableSets", Filters.eq(PRIVATE_UID, variableSetId)); if (options == null) { options = new QueryOptions(); } QueryOptions qOptions = new QueryOptions(options); qOptions.put(MongoDBCollection.ELEM_MATCH, projection); QueryResult<Study> studyQueryResult = get(query, qOptions); if (studyQueryResult.getResult().isEmpty() || studyQueryResult.first().getVariableSets().isEmpty()) { throw new CatalogDBException("VariableSet {id: " + variableSetId + "} does not exist."); } return endQuery("", startTime, studyQueryResult.first().getVariableSets()); }
return; if (study.getVariableSets() == null) { throw new CatalogException("Internal error. VariableSets should be provided in the study parameter.");
for (Document studyDocument : queryResult.getResult()) { Study study = studyConverter.convertToDataModelType(studyDocument); VariableSet vs = study.getVariableSets().get(0); if (!vs.isConfidential() || hasConfidentialPermission) { variableSets.add(vs);
/** * VariableSet methods * *************************** */ @Test public void testCreateVariableSet() throws CatalogException { Study study = catalogManager.getStudyManager().get("user@1000G:phase1", null, sessionIdUser).first(); long variableSetNum = study.getVariableSets().size(); List<Variable> variables = new ArrayList<>(); variables.addAll(Arrays.asList( new Variable("NAME", "", Variable.VariableType.TEXT, "", true, false, Collections.<String>emptyList(), 0, "", "", null, Collections.<String, Object>emptyMap()), new Variable("AGE", "", Variable.VariableType.DOUBLE, null, true, false, Collections.singletonList("0:99"), 1, "", "", null, Collections.<String, Object>emptyMap()), new Variable("HEIGHT", "", Variable.VariableType.DOUBLE, "1.5", false, false, Collections.singletonList("0:"), 2, "", "", null, Collections.<String, Object>emptyMap()), new Variable("ALIVE", "", Variable.VariableType.BOOLEAN, "", true, false, Collections.<String>emptyList(), 3, "", "", null, Collections.<String, Object>emptyMap()), new Variable("PHEN", "", Variable.VariableType.CATEGORICAL, "", true, false, Arrays.asList("CASE", "CONTROL"), 4, "", "", null, Collections.<String, Object>emptyMap()) )); QueryResult<VariableSet> queryResult = catalogManager.getStudyManager().createVariableSet(studyFqn, "vs1", "vs1", true, false, "", null, variables, sessionIdUser); assertEquals(1, queryResult.getResult().size()); study = catalogManager.getStudyManager().get(study.getId(), null, sessionIdUser).first(); assertEquals(variableSetNum + 1, study.getVariableSets().size()); }
SolrQuery solrQuery = catalogSolrQueryParser.parse(queryCopy, queryOptionsCopy, study.getVariableSets());
Study study = catalogManager.getStudyManager().get(studyFqn, null, sessionIdUser).first(); long variableSetId = study.getVariableSets().get(0).getUid();
@Test public void testProjections() throws CatalogException { Study study = catalogManager.getStudyManager().get("1000G:phase1", null, sessionIdUser).first(); Query query = new Query(Constants.ANNOTATION, "variableSet===" + study.getVariableSets().get(0).getId()); QueryOptions options = new QueryOptions(QueryOptions.INCLUDE, "annotationSets"); QueryResult<Sample> annotQueryResult = catalogManager.getSampleManager().search(studyFqn, query, options, sessionIdUser); assertEquals(8, annotQueryResult.getNumResults()); for (Sample sample : annotQueryResult.getResult()) { assertEquals(null, sample.getId()); assertTrue(!sample.getAnnotationSets().isEmpty()); } }
public void testAnnotateIndividual() throws CatalogException { Study study = catalogManager.getStudyManager().get(studyFqn, null, sessionIdUser).first(); VariableSet variableSet = study.getVariableSets().get(0);
Study study = catalogManager.getStudyManager().get(studyFqn, QueryOptions.empty(), sessionIdUser).first(); VariableSet variableSet = study.getVariableSets().get(0);
query.put(Constants.ANNOTATION, "variableSet===" + study.getVariableSets().get(0).getId()); annotQueryResult = catalogManager.getSampleManager().search(studyFqn, query, QueryOptions.empty(), sessionIdUser); assertEquals(7, annotQueryResult.getNumResults());
.setStatus(study.getStatus()) .setType(study.getType()) .setVariableSets(study.getVariableSets());