-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-2.12.x' into TASK-6117
- Loading branch information
Showing
77 changed files
with
996 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
* @author Jacobo Coll <[email protected]> | ||
*/ | ||
public class CohortMetadata extends StudyResourceMetadata<CohortMetadata> { | ||
public static final String INVALID_STATS_NUM_SAMPLES = "invalidStatsNumSamples"; | ||
|
||
// private int studyId; | ||
// private int id; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,12 @@ | |
import org.opencb.commons.datastore.core.DataResult; | ||
import org.opencb.commons.datastore.core.Query; | ||
import org.opencb.commons.datastore.core.QueryOptions; | ||
import org.opencb.opencga.core.response.VariantQueryResult; | ||
import org.opencb.opencga.storage.core.metadata.VariantStorageMetadataManager; | ||
import org.opencb.opencga.storage.core.metadata.models.StudyMetadata; | ||
import org.opencb.opencga.storage.core.variant.adaptors.iterators.VariantDBIterator; | ||
import org.opencb.opencga.storage.core.variant.query.ParsedVariantQuery; | ||
import org.opencb.opencga.storage.core.variant.query.VariantQueryParser; | ||
import org.opencb.opencga.storage.core.variant.query.VariantQueryResult; | ||
import org.opencb.opencga.storage.core.variant.query.projection.VariantQueryProjectionParser; | ||
import org.opencb.opencga.storage.core.variant.stats.VariantStatsWrapper; | ||
|
||
|
@@ -37,30 +37,13 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.opencb.opencga.storage.core.variant.query.VariantQueryUtils.addSamplesMetadataIfRequested; | ||
|
||
/** | ||
* @author Ignacio Medina <[email protected]> | ||
* @author Jacobo Coll <[email protected]> | ||
* @author Cristina Yenyxe Gonzalez Garcia <[email protected]> | ||
*/ | ||
public interface VariantDBAdaptor extends VariantIterable, AutoCloseable { | ||
|
||
/** | ||
* This method inserts Variants into the given Study. If the Study already exists then it just adds the new Sample | ||
* genotypes, also new variants are inserted. If it is a new Study then Sample genotypes are added to the new Study. | ||
* | ||
* @param variants List of variants in OpenCB data model to be inserted | ||
* @param studyName Name or alias of the study | ||
* @param options Query modifiers, accepted values are: include, exclude, limit, skip, sort and count | ||
* @return A DataResult with the number of inserted variants | ||
*/ | ||
@Deprecated | ||
default DataResult insert(List<Variant> variants, String studyName, QueryOptions options) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
/** | ||
/** | ||
* Fetch all variants resulting of executing the query in the database. Returned fields are taken from | ||
* the 'include' and 'exclude' fields at options. | ||
|
@@ -71,26 +54,29 @@ default DataResult insert(List<Variant> variants, String studyName, QueryOptions | |
* @return A DataResult with the result of the query | ||
*/ | ||
default VariantQueryResult<Variant> get(Iterator<?> variants, Query query, QueryOptions options) { | ||
DataResult<Variant> queryResult = iterator(variants, query, options).toDataResult(); | ||
return addSamplesMetadataIfRequested(queryResult, query, options, getMetadataManager()); | ||
ParsedVariantQuery variantQuery = new VariantQueryParser(null, getMetadataManager()).parseQuery(query, options, true); | ||
try (VariantDBIterator iterator = iterator(variants, query, options)) { | ||
return iterator.toDataResult(variantQuery); | ||
} catch (Exception e) { | ||
throw VariantQueryException.internalException(e); | ||
} | ||
} | ||
|
||
@Deprecated | ||
default VariantDBIterator iterator(Query query, QueryOptions options) { | ||
return iterator(new VariantQueryParser(null, getMetadataManager()).parseQuery(query, options, true), options); | ||
return iterator(new VariantQueryParser(null, getMetadataManager()).parseQuery(query, options, true)); | ||
} | ||
|
||
VariantDBIterator iterator(ParsedVariantQuery query, QueryOptions options); | ||
VariantDBIterator iterator(ParsedVariantQuery query); | ||
|
||
/** | ||
* Fetch all variants resulting of executing the query in the database. Returned fields are taken from | ||
* the 'include' and 'exclude' fields at options. | ||
* | ||
* @param query Query to be executed in the database to filter variants | ||
* @param options Query modifiers, accepted values are: include, exclude, limit, skip, sort and count | ||
* @return A DataResult with the result of the query | ||
*/ | ||
VariantQueryResult<Variant> get(ParsedVariantQuery query, QueryOptions options); | ||
VariantQueryResult<Variant> get(ParsedVariantQuery query); | ||
|
||
/** | ||
* Fetch all variants resulting of executing the query in the database. Returned fields are taken from | ||
|
@@ -102,7 +88,7 @@ default VariantDBIterator iterator(Query query, QueryOptions options) { | |
*/ | ||
@Deprecated | ||
default VariantQueryResult<Variant> get(Query query, QueryOptions options) { | ||
return get(new VariantQueryParser(null, getMetadataManager()).parseQuery(query, options, true), options); | ||
return get(new VariantQueryParser(null, getMetadataManager()).parseQuery(query, options, true)); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
...va/org/opencb/opencga/storage/core/variant/adaptors/iterators/LimitVariantDBIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
package org.opencb.opencga.storage.core.variant.adaptors.iterators; | ||
|
||
import org.opencb.biodata.models.variant.Variant; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
public class LimitVariantDBIterator extends DelegatedVariantDBIterator { | ||
|
||
private final int limit; | ||
private int count; | ||
|
||
LimitVariantDBIterator(VariantDBIterator delegated, int limit) { | ||
super(delegated); | ||
this.limit = limit; | ||
this.count = 0; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return getCount() < limit && super.hasNext(); | ||
return count < limit && super.hasNext(); | ||
} | ||
|
||
@Override | ||
public Variant next() { | ||
if (!this.hasNext()) { | ||
throw new NoSuchElementException(); | ||
} else { | ||
++this.count; | ||
return super.next(); | ||
} | ||
} | ||
} |
Oops, something went wrong.