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 @@ -156,7 +156,7 @@ private static int getIncrement(Document genomeAlignment){
return genomeAlignment.getInteger(SchemaConstants.Field.ORIENTATION);
}

private static List<Integer> mapToGenomeIndex(int proteinIndex, Range proteinRange, Range genomeRange){
public static List<Integer> mapToGenomeIndex(int proteinIndex, Range proteinRange, Range genomeRange){
if(!proteinRange.contains(proteinIndex))
return List.of();
int begin = 3 * (proteinIndex - proteinRange.bottom()) + genomeRange.bottom();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
package org.rcsb.rcsbsequencecoordinates.collectors.annotations;

import org.bson.Document;
import org.rcsb.rcsbsequencecoordinates.collectors.alignments.AlignmentsCollector;
import org.rcsb.rcsbsequencecoordinates.collectors.alignments.SequenceAlignmentsCollector;
import org.rcsb.rcsbsequencecoordinates.collectors.utils.AnnotationFilterOperator;
import org.rcsb.rcsbsequencecoordinates.collectors.utils.AnnotationRangeIntersection;
import org.rcsb.rcsbsequencecoordinates.collectors.utils.RangeIntersectionOperator;
import org.rcsb.graphqlschema.params.AnnotationFilter;
import org.rcsb.graphqlschema.reference.AnnotationReference;
import org.rcsb.graphqlschema.reference.GroupReference;
Expand Down Expand Up @@ -46,10 +45,10 @@ public Flux<Document> getAnnotations(
List<AnnotationFilter> annotationFilters,
List<Integer> range
) {
RangeIntersectionOperator annotationRangeIntersection = new RangeIntersectionOperator(range, new AnnotationRangeIntersection());
return getAnnotations(queryId, sequenceReference, annotationReferences, annotationFilters)
.filter(annotationRangeIntersection::isConnected)
.map(annotationRangeIntersection::applyRange);
return Flux.fromIterable(annotationReferences)
.flatMap(
annotationReference -> getAnnotations(queryId, sequenceReference, annotationReference, annotationFilters, range)
);
}

public Flux<Document> getAnnotations(
Expand All @@ -59,25 +58,13 @@ public Flux<Document> getAnnotations(
List<AnnotationFilter> annotationFilters
){
if(groupReference.equals(GroupReference.MATCHING_UNIPROT_ACCESSION))
return getAnnotations(groupId, SequenceReference.UNIPROT, annotationReferences, annotationFilters);
return getAnnotations(groupId, SequenceReference.UNIPROT, annotationReferences, annotationFilters, null);
return Flux.fromIterable(annotationReferences)
.flatMap(
annotationReference -> getAnnotations(groupId, groupReference, annotationReference, annotationFilters)
);
}

private Flux<Document> getAnnotations(
String queryId,
SequenceReference sequenceReference,
List<AnnotationReference> annotationReferences,
List<AnnotationFilter> annotationFilters
) {
return Flux.fromIterable(annotationReferences)
.flatMap(
annotationReference -> getAnnotations(queryId, sequenceReference, annotationReference, annotationFilters)
);
}

private Flux<Document> getAnnotations(
String groupId,
GroupReference groupReference,
Expand Down Expand Up @@ -126,14 +113,18 @@ private Flux<Document> getAnnotations(
String queryId,
SequenceReference sequenceReference,
AnnotationReference annotationReference,
List<AnnotationFilter> annotationFilters
List<AnnotationFilter> annotationFilters,
List<Integer> range
) {
return sequenceAlignmentsCollector
AlignmentsCollector alignmentsCollector = sequenceAlignmentsCollector
.request(
queryId,
sequenceReference,
annotationReference.toSequenceReference()
)
queryId,
sequenceReference,
annotationReference.toSequenceReference()
);
if(range != null)
alignmentsCollector.range(range);
return alignmentsCollector
.get()
.flatMap(
alignment -> getAnnotations(annotationReference, annotationFilters, alignment)
Expand All @@ -152,7 +143,8 @@ private Flux<Document> getAnnotations(
.filter(filter::targetCheck)
.map(filter::applyFilterToFeatures)
.filter(AnnotationsHelper::hasFeatures)
.map(annotations -> mapAnnotations(annotations, alignment));
.map(annotations -> mapAnnotations(annotations, alignment))
.filter(annotations -> !annotations.isEmpty());
}

private Flux<Document> switchAlignmentEntityIdToReference(Document alignment, SequenceReference reference){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static com.mongodb.client.model.Filters.eq;
import static com.mongodb.client.model.Filters.or;
import static com.mongodb.client.model.Projections.*;
import static org.rcsb.rcsbsequencecoordinates.collectors.alignments.GenomeAlignmentsHelper.mapToGenomeIndex;
import static org.rcsb.rcsbsequencecoordinates.collectors.map.MapHelper.parseAsymFromInstance;
import static org.rcsb.rcsbsequencecoordinates.collectors.map.MapHelper.parseEntryFromInstance;
import static org.rcsb.utils.RangeMethods.intersection;
Expand Down Expand Up @@ -69,12 +70,15 @@ public static List<Bson> getAggregation(List<String> ids){
}

public static Document mapAnnotations(Document annotations, Document alignment){
List<Document> features = annotations.getList(SequenceCoordinatesConstants.FEATURES, Document.class).stream()
.map(feature-> mapFeature(feature, alignment))
.filter(d->!d.getList(SequenceCoordinatesConstants.FEATURE_POSITIONS, Document.class).isEmpty())
.toList();
if (features.isEmpty())
return new Document();
annotations.put(
SchemaConstants.Field.FEATURES,
annotations.getList(SequenceCoordinatesConstants.FEATURES, Document.class).stream()
.map(feature-> mapFeature(feature, alignment))
.filter(d->!d.getList(SequenceCoordinatesConstants.FEATURE_POSITIONS, Document.class).isEmpty())
.toList()
features
);
return annotations;
}
Expand Down Expand Up @@ -164,7 +168,9 @@ private static Document valuesIntersection(Document featureRegion, Document alig
alignmentRegion.getInteger(SequenceCoordinatesConstants.QUERY_END)
);
return new Document(Map.of(
SchemaConstants.Field.BEG_SEQ_ID, mapIndex(intersection.bottom(), targetRange, queryRange),
SchemaConstants.Field.BEG_SEQ_ID, alignmentRegion.containsKey(SequenceCoordinatesConstants.EXON_SHIFT) ?
mapToGenomeIndex(intersection.bottom(), targetRange, queryRange).get(0) :
mapIndex(intersection.bottom(), targetRange, queryRange),
SchemaConstants.Field.BEG_ORI_ID, intersection.bottom(),
SchemaConstants.Field.VALUES, featureValues.subList(
intersection.bottom() - featureRange.bottom(),
Expand Down Expand Up @@ -195,8 +201,12 @@ private static Document regionIntersection(Document featureRegion, Document alig
alignmentRegion.getInteger(SequenceCoordinatesConstants.QUERY_END)
);
return new Document(Map.of(
SchemaConstants.Field.BEG_SEQ_ID, mapIndex(intersection.bottom(), targetRange, queryRange),
SchemaConstants.Field.END_SEQ_ID, mapIndex(intersection.top(), targetRange, queryRange),
SchemaConstants.Field.BEG_SEQ_ID, alignmentRegion.containsKey(SequenceCoordinatesConstants.EXON_SHIFT) ?
mapToGenomeIndex(intersection.bottom(), targetRange, queryRange).get(0) :
mapIndex(intersection.bottom(), targetRange, queryRange),
SchemaConstants.Field.END_SEQ_ID, alignmentRegion.containsKey(SequenceCoordinatesConstants.EXON_SHIFT) ?
mapToGenomeIndex(intersection.top(), targetRange, queryRange).get(2) :
mapIndex(intersection.top(), targetRange, queryRange),
SchemaConstants.Field.BEG_ORI_ID, intersection.bottom(),
SchemaConstants.Field.END_ORI_ID, intersection.top(),
SchemaConstants.Field.OPEN_BEGIN, intersection.bottom() != featureRegion.getInteger(SequenceCoordinatesConstants.BEG_SEQ_ID),
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/static/graphiql/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>GraphiQL</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RCSB PDB Sequence Coordinates - GraphiQL</title>
<style>
body {
height: 100%;
Expand Down
Loading