├── src ├── main │ ├── resources │ │ ├── application.properties │ │ └── logback.xml │ └── java │ │ └── org │ │ └── reactome │ │ └── server │ │ └── graph │ │ ├── domain │ │ ├── schema │ │ │ ├── SchemaCreator.java │ │ │ ├── SchemaDataCatalog.java │ │ │ ├── SchemaOrganization.java │ │ │ ├── SchemaDataDownload.java │ │ │ ├── SchemaDataDownloadType.java │ │ │ └── SchemaPerson.java │ │ ├── model │ │ │ ├── Anatomy.java │ │ │ ├── ReactionType.java │ │ │ ├── MetaDatabaseObject.java │ │ │ ├── DeletedControlledVocabulary.java │ │ │ ├── NonsenseMutation.java │ │ │ ├── ReviewStatus.java │ │ │ ├── Disease.java │ │ │ ├── CellType.java │ │ │ ├── RNADrug.java │ │ │ ├── ChemicalDrug.java │ │ │ ├── GO_BiologicalProcess.java │ │ │ ├── ProteinDrug.java │ │ │ ├── SequenceOntology.java │ │ │ ├── NegativePrecedingEventReason.java │ │ │ ├── TranscriptionalModification.java │ │ │ ├── FragmentDeletionModification.java │ │ │ ├── IntraChainCrosslinkedResidue.java │ │ │ ├── ReferenceDNASequence.java │ │ │ ├── GeneticallyModifiedResidue.java │ │ │ ├── Deletable.java │ │ │ ├── Compartment.java │ │ │ ├── EvidenceType.java │ │ │ ├── Trackable.java │ │ │ ├── ModifiedResidue.java │ │ │ ├── Depolymerisation.java │ │ │ ├── PsiMod.java │ │ │ ├── RegulationType.java │ │ │ ├── ReferenceGroup.java │ │ │ ├── Species.java │ │ │ ├── CellDevelopmentStep.java │ │ │ ├── Ontology.java │ │ │ ├── Requirement.java │ │ │ ├── GO_MolecularFunction.java │ │ │ ├── Figure.java │ │ │ ├── RegulationReference.java │ │ │ ├── InteractionEvent.java │ │ │ ├── NegativeGeneExpressionRegulation.java │ │ │ ├── PositiveGeneExpressionRegulation.java │ │ │ ├── DrugActionType.java │ │ │ ├── URL.java │ │ │ ├── DefinedSet.java │ │ │ ├── FragmentInsertionModification.java │ │ │ ├── Drug.java │ │ │ ├── TopLevelPathway.java │ │ │ ├── CatalystActivityReference.java │ │ │ ├── FragmentReplacedModification.java │ │ │ ├── ControlReference.java │ │ │ ├── ReferenceRNASequence.java │ │ │ ├── PositiveRegulation.java │ │ │ ├── AbstractModifiedResidue.java │ │ │ ├── Affiliation.java │ │ │ ├── NegativeRegulation.java │ │ │ ├── DrugType.java │ │ │ ├── ControlledVocabulary.java │ │ │ ├── DBInfo.java │ │ │ ├── FunctionalStatusType.java │ │ │ ├── Polymerisation.java │ │ │ ├── UndirectedInteraction.java │ │ │ ├── MarkerReference.java │ │ │ ├── GroupModifiedResidue.java │ │ │ ├── CellLineagePath.java │ │ │ ├── ModifiedNucleotide.java │ │ │ ├── ReplacedResidue.java │ │ │ ├── Summation.java │ │ │ ├── FunctionalStatus.java │ │ │ ├── ReferenceMolecule.java │ │ │ ├── OtherEntity.java │ │ │ ├── DirectedInteraction.java │ │ │ ├── ReferenceIsoform.java │ │ │ ├── Release.java │ │ │ ├── FragmentModification.java │ │ │ ├── InterChainCrosslinkedResidue.java │ │ │ ├── InstanceEdit.java │ │ │ ├── NegativePrecedingEvent.java │ │ │ ├── FailedReaction.java │ │ │ ├── GenomeEncodedEntity.java │ │ │ ├── TranslationalModification.java │ │ │ ├── EntityFunctionalStatus.java │ │ │ ├── Publication.java │ │ │ ├── BlackBoxEvent.java │ │ │ ├── ReferenceGeneProduct.java │ │ │ ├── Book.java │ │ │ ├── Taxon.java │ │ │ ├── CrosslinkedResidue.java │ │ │ ├── ReferenceTherapeutic.java │ │ │ ├── UpdateTracker.java │ │ │ ├── Reaction.java │ │ │ ├── GO_CellularComponent.java │ │ │ ├── DatabaseIdentifier.java │ │ │ ├── LiteratureReference.java │ │ │ ├── DeletedInstance.java │ │ │ ├── Interaction.java │ │ │ ├── ReferenceDatabase.java │ │ │ └── GO_Term.java │ │ ├── result │ │ │ ├── DatabaseObjectLike.java │ │ │ ├── HierarchyBranch.java │ │ │ ├── CustomQuery.java │ │ │ ├── EventProjectionWrapper.java │ │ │ ├── InteractorsCount.java │ │ │ ├── Referrals.java │ │ │ ├── HierarchyWrapper.java │ │ │ ├── SchemaClassCount.java │ │ │ ├── SimpleReferenceObject.java │ │ │ ├── DiagramResult.java │ │ │ ├── DiagramOccurrences.java │ │ │ ├── QueryResultWrapper.java │ │ │ └── PersonAuthorReviewer.java │ │ ├── annotations │ │ │ ├── StoichiometryView.java │ │ │ ├── ReactomeProjectedRelationship.java │ │ │ ├── ReactomeSchemaIgnore.java │ │ │ ├── ReactomeAllowedClasses.java │ │ │ ├── ReactomeProperty.java │ │ │ ├── ReactomeRelationship.java │ │ │ └── ReactomeTransient.java │ │ └── relationship │ │ │ ├── HasEvent.java │ │ │ ├── EventOf.java │ │ │ ├── HasEncapsulatedEvent.java │ │ │ ├── InputForReactionLikeEvent.java │ │ │ ├── HasMember.java │ │ │ ├── Output.java │ │ │ ├── Input.java │ │ │ ├── HasCandidate.java │ │ │ ├── AuthorPublication.java │ │ │ ├── RepeatedUnitForPhysicalEntity.java │ │ │ ├── DiseaseReaction.java │ │ │ ├── RepeatedUnit.java │ │ │ ├── PublicationAuthor.java │ │ │ ├── OutputForReactionLikeEvent.java │ │ │ ├── HasComponent.java │ │ │ ├── ComponentOf.java │ │ │ ├── HasCompartment.java │ │ │ ├── MemberOf.java │ │ │ ├── CandidateOf.java │ │ │ ├── HasModifiedResidue.java │ │ │ └── CompositionAggregator.java │ │ ├── service │ │ ├── helper │ │ │ ├── RelationshipDirection.java │ │ │ ├── AttributeClass.java │ │ │ ├── StoichiometryObject.java │ │ │ ├── EnhancedQueryOptions.java │ │ │ ├── AttributeProperties.java │ │ │ └── ContentDetails.java │ │ ├── DoiService.java │ │ ├── ReferenceEntityService.java │ │ ├── DeletedInstanceService.java │ │ ├── TocService.java │ │ ├── DeletedService.java │ │ ├── UpdateTrackerService.java │ │ ├── DiagramService.java │ │ ├── OrthologyService.java │ │ ├── TopLevelPathwayService.java │ │ └── AdvancedLinkageService.java │ │ ├── exception │ │ └── CustomQueryException.java │ │ ├── repository │ │ ├── DBInfoRepository.java │ │ ├── util │ │ │ └── RepositoryUtils.java │ │ ├── GeneralRepository.java │ │ ├── DeletedInstanceRepository.java │ │ ├── PublicationRepository.java │ │ ├── SpeciesRepository.java │ │ ├── UpdateTrackerRepository.java │ │ ├── InteractorCountRepository.java │ │ ├── DeletedRepository.java │ │ ├── OrthologyRepository.java │ │ ├── PersonRepository.java │ │ ├── ReferenceEntityRepository.java │ │ ├── TopLevelPathwayRepository.java │ │ └── CustomInteractionsRepository.java │ │ ├── Main.java │ │ ├── config │ │ └── GraphCoreNeo4jConfig.java │ │ └── aop │ │ └── LoggingAspect.java └── test │ ├── resources │ ├── db.properties │ ├── application.properties │ └── logback-test.xml │ └── java │ └── org │ └── reactome │ └── server │ └── graph │ ├── custom │ ├── CustomReference.java │ ├── CustomQueryPhysicalEntity.java │ └── CustomQueryResult.java │ └── service │ ├── DoiServiceTest.java │ ├── TocServiceTest.java │ ├── DeletedInstanceServiceTest.java │ ├── ReferenceEntityServiceTest.java │ ├── OrthologyServiceTest.java │ ├── DeletedServiceTest.java │ ├── CompartmentTest.java │ ├── AdvancedLinkageServiceTest.java │ └── BaseTest.java ├── .gitignore ├── update_major_version.sh └── release_github.sh /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # intelliJ idea git ignore 2 | *.iml 3 | *.idea 4 | *.log 5 | *target* 6 | *.txt -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/schema/SchemaCreator.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.schema; 2 | 3 | public abstract class SchemaCreator { 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/db.properties: -------------------------------------------------------------------------------- 1 | database.host=@mysql.host@ 2 | database.name=@mysql.reactome.database@ 3 | database.user=@mysql.user@ 4 | database.password=@mysql.password@ 5 | database.port=@mysql.port@ 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Anatomy.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public class Anatomy extends ExternalOntology { 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReactionType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public abstract class ReactionType extends ControlledVocabulary { 7 | 8 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/MetaDatabaseObject.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public abstract class MetaDatabaseObject extends DatabaseObject{ 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DeletedControlledVocabulary.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public class DeletedControlledVocabulary extends ControlledVocabulary{ 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/DatabaseObjectLike.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | public interface DatabaseObjectLike { 4 | Long getDbId(); 5 | String getStId(); 6 | String getDisplayName(); 7 | String getSchemaClass(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/NonsenseMutation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public class NonsenseMutation extends ReplacedResidue { 7 | 8 | public NonsenseMutation() { } 9 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReviewStatus.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public class ReviewStatus extends ControlledVocabulary { 7 | 8 | public ReviewStatus() { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/StoichiometryView.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | public class StoichiometryView { 4 | 5 | public interface Flatten { } 6 | 7 | public interface Nested { } 8 | 9 | public interface NestedAggregated extends Nested { } 10 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Disease.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class Disease extends ExternalOntology { 8 | 9 | public Disease() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/CellType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class CellType extends ExternalOntology { 8 | 9 | public CellType() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/RNADrug.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings({"unused", "WeakerAccess"}) 6 | @Node 7 | public class RNADrug extends Drug { 8 | 9 | public RNADrug() { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ChemicalDrug.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings({"unused", "WeakerAccess"}) 6 | @Node 7 | public class ChemicalDrug extends Drug { 8 | 9 | public ChemicalDrug() { 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GO_BiologicalProcess.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class GO_BiologicalProcess extends GO_Term{ 8 | 9 | public GO_BiologicalProcess() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ProteinDrug.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings({"unused", "WeakerAccess"}) 6 | @Node 7 | public class ProteinDrug extends Drug { 8 | 9 | public ProteinDrug() { 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/helper/RelationshipDirection.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service.helper; 2 | 3 | /** 4 | * Created by: 5 | * 6 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 7 | * @since 14.04.16. 8 | */ 9 | public enum RelationshipDirection { 10 | INCOMING, OUTGOING, UNDIRECTED 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/SequenceOntology.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class SequenceOntology extends ExternalOntology { 8 | 9 | public SequenceOntology() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/NegativePrecedingEventReason.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public class NegativePrecedingEventReason extends ControlledVocabulary { 7 | 8 | public NegativePrecedingEventReason() { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/TranscriptionalModification.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public abstract class TranscriptionalModification extends AbstractModifiedResidue { 8 | 9 | public TranscriptionalModification() { } 10 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FragmentDeletionModification.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class FragmentDeletionModification extends FragmentModification { 8 | 9 | public FragmentDeletionModification() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/IntraChainCrosslinkedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class IntraChainCrosslinkedResidue extends CrosslinkedResidue { 8 | 9 | public IntraChainCrosslinkedResidue() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceDNASequence.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class ReferenceDNASequence extends ReferenceSequence { 8 | 9 | public ReferenceDNASequence() { 10 | super(); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GeneticallyModifiedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public abstract class GeneticallyModifiedResidue extends AbstractModifiedResidue { 8 | 9 | public GeneticallyModifiedResidue() {} 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Deletable.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | 4 | import org.reactome.server.graph.domain.result.DatabaseObjectLike; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | import java.util.List; 8 | 9 | @Node 10 | public interface Deletable extends DatabaseObjectLike { 11 | List getDeleted(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Compartment.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class Compartment extends GO_CellularComponent { 8 | 9 | public Compartment() {} 10 | public Compartment(Long dbId) { 11 | super(dbId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/EvidenceType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class EvidenceType extends ExternalOntology { 9 | 10 | public EvidenceType() { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Trackable.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | 4 | import org.reactome.server.graph.domain.result.DatabaseObjectLike; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | import java.util.List; 8 | 9 | @Node 10 | public interface Trackable extends DatabaseObjectLike { 11 | 12 | List getUpdateTrackers(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ModifiedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @SuppressWarnings("unused") 6 | @Node 7 | public class ModifiedResidue extends TranslationalModification { 8 | 9 | public ModifiedResidue() {} 10 | 11 | public ModifiedResidue(Long dbId) { 12 | super(dbId); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/exception/CustomQueryException.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.exception; 2 | 3 | /** 4 | * @author Guilherme S Viteri 5 | */ 6 | 7 | public class CustomQueryException extends Exception { 8 | 9 | public CustomQueryException(String message) { 10 | super(message); 11 | } 12 | 13 | public CustomQueryException(Throwable cause) { 14 | super(cause); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/HierarchyBranch.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import java.util.List; 4 | 5 | public class HierarchyBranch { 6 | 7 | private List branch; 8 | 9 | public List getPathways(){ 10 | return branch; 11 | } 12 | 13 | public HierarchyBranch(List branch) { 14 | this.branch = branch; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/ReactomeProjectedRelationship.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface ReactomeProjectedRelationship { 11 | String value(); 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.neo4j.uri=@neo4j.uri@ 2 | spring.neo4j.authentication.username=@neo4j.user@ 3 | spring.neo4j.authentication.password=@neo4j.password@ 4 | 5 | spring.data.neo4j.database=@neo4j.database@ 6 | 7 | spring.main.allow-bean-definition-overriding=true 8 | 9 | logging.level.org.springframework.data.neo4j.cypher = trace 10 | logging.level.org.springframework.data.neo4j.repository = trace 11 | logging.level.org.springframework.data.neo4j.core.mapping = trace -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Depolymerisation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | /** 6 | * Reactions that follow the pattern: Polymer - Polymer + Unit (there may be a catalyst involved). Used to describe the mechanistic detail of depolymerisation 7 | */ 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class Depolymerisation extends ReactionLikeEvent { 11 | 12 | public Depolymerisation() {} 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/DBInfoRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.DBInfo; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public interface DBInfoRepository extends Neo4jRepository { 10 | @Query("MATCH (db:DBInfo) RETURN db LIMIT 1") 11 | DBInfo getDBInfo(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/ReactomeSchemaIgnore.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * This annotation is used to mark the fields that should not be added in the schema documentation 10 | * 11 | */ 12 | @Target({ElementType.METHOD}) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | public @interface ReactomeSchemaIgnore {} -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/PsiMod.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class PsiMod extends ExternalOntology { 9 | 10 | @ReactomeProperty 11 | private String label; 12 | 13 | public PsiMod() {} 14 | 15 | public String getLabel() { 16 | return label; 17 | } 18 | 19 | public void setLabel(String label) { 20 | this.label = label; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/ReactomeAllowedClasses.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @Target({ElementType.FIELD, ElementType.METHOD}) 11 | @Retention(RetentionPolicy.RUNTIME) 12 | public @interface ReactomeAllowedClasses { 13 | Class[] allowed() default DatabaseObject.class; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/schema/SchemaDataCatalog.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.schema; 2 | 3 | import com.fasterxml.jackson.annotation.JsonGetter; 4 | 5 | public class SchemaDataCatalog { 6 | 7 | private static final String URL = "https://reactome.org"; 8 | private static final String NAME = "Reactome"; 9 | 10 | public String getUrl() { 11 | return URL; 12 | } 13 | 14 | public String getName() { 15 | return NAME; 16 | } 17 | 18 | @JsonGetter(value = "@type") 19 | public String getType(){ 20 | return "DataCatalog"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/RegulationType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @Deprecated 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class RegulationType extends DatabaseObject { 10 | 11 | @ReactomeProperty 12 | private String name; 13 | 14 | public RegulationType() {} 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceGroup.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class ReferenceGroup extends ReferenceEntity { 9 | 10 | @ReactomeProperty 11 | private String formula; 12 | 13 | public ReferenceGroup() {} 14 | 15 | public String getFormula() { 16 | return formula; 17 | } 18 | 19 | public void setFormula(String formula) { 20 | this.formula = formula; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Species.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class Species extends Taxon { 9 | 10 | @ReactomeProperty 11 | private String abbreviation; 12 | 13 | public Species() {} 14 | 15 | public String getAbbreviation() { 16 | return abbreviation; 17 | } 18 | 19 | public void setAbbreviation(String abbreviation) { 20 | this.abbreviation = abbreviation; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/util/RepositoryUtils.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository.util; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | /** 6 | * Created by: 7 | * 8 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 9 | * @since 10.11.15. 10 | */ 11 | public class RepositoryUtils { 12 | 13 | public static String getRelationshipAsString (String... relationships) { 14 | String result = ""; 15 | if (relationships != null && relationships.length > 0) { 16 | result = ":" + StringUtils.join(relationships, "|"); 17 | } 18 | return result; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/CellDevelopmentStep.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | @Node 7 | public class CellDevelopmentStep extends ReactionLikeEvent { 8 | 9 | @Relationship(type = "tissue") 10 | private Anatomy tissue; 11 | 12 | public CellDevelopmentStep() { 13 | 14 | } 15 | 16 | public Anatomy getTissue() { 17 | return tissue; 18 | } 19 | 20 | public void setTissue(Anatomy tissue) { 21 | this.tissue = tissue; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Ontology.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Deprecated 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class Ontology extends DatabaseObject { 9 | 10 | private byte[] ontology; 11 | 12 | public Ontology() {} 13 | 14 | public Ontology(byte[] ontology) { 15 | this.ontology = ontology; 16 | } 17 | 18 | public byte[] getOntology() { 19 | return this.ontology; 20 | } 21 | 22 | public void setOntology(byte[] ontology) { 23 | this.ontology = ontology; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Requirement.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class Requirement extends PositiveRegulation { 10 | 11 | public Requirement() {} 12 | 13 | @ReactomeSchemaIgnore 14 | @Override 15 | @JsonIgnore 16 | public String getExplanation() { 17 | return "A regulator that is required for an Event/CatalystActivity to happen"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/schema/SchemaOrganization.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.schema; 2 | 3 | import com.fasterxml.jackson.annotation.JsonGetter; 4 | import org.reactome.server.graph.domain.model.Affiliation; 5 | 6 | public class SchemaOrganization extends SchemaCreator { 7 | private final String name; 8 | 9 | SchemaOrganization(Affiliation affiliation) { 10 | this.name = affiliation.getDisplayName(); 11 | } 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | @JsonGetter(value = "@type") 18 | public String getType(){ 19 | return "Organization"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/helper/AttributeClass.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service.helper; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | 5 | public class AttributeClass { 6 | 7 | private Class type; 8 | private boolean valueTypeDatabaseObject; 9 | 10 | public AttributeClass(Class type) { 11 | this.type = type; 12 | valueTypeDatabaseObject = DatabaseObject.class.isAssignableFrom(type); 13 | } 14 | 15 | public Class getType() { 16 | return type; 17 | } 18 | 19 | public boolean isValueTypeDatabaseObject() { 20 | return valueTypeDatabaseObject; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GO_MolecularFunction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class GO_MolecularFunction extends GO_Term { 9 | 10 | @ReactomeProperty 11 | private String ecNumber; 12 | 13 | public GO_MolecularFunction() {} 14 | 15 | 16 | public String getEcNumber() { 17 | return ecNumber; 18 | } 19 | 20 | public void setEcNumber(String ecNumber) { 21 | this.ecNumber = ecNumber; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Figure.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Property; 6 | 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class Figure extends DatabaseObject { 10 | 11 | @ReactomeProperty 12 | @Property 13 | private String url; 14 | 15 | public Figure() {} 16 | 17 | public String getUrl() { 18 | return this.url; 19 | } 20 | 21 | public void setUrl(String url) { 22 | this.url = url; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/RegulationReference.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | @Node 7 | public class RegulationReference extends ControlReference { 8 | 9 | @Relationship(type = "regulation") 10 | private Regulation regulation; 11 | 12 | public RegulationReference() { 13 | } 14 | 15 | public Regulation getRegulatedBy() { 16 | return regulation; 17 | } 18 | 19 | public void setRegulatedBy(Regulation regulation) { 20 | this.regulation = regulation; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Event; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | @RelationshipProperties 8 | public class HasEvent extends Has { 9 | 10 | @Override 11 | public String getType() { 12 | return "event"; 13 | } 14 | 15 | @JsonIgnore 16 | public Event getEvent() { 17 | return element; 18 | } 19 | 20 | public void setEvent(Event hasEvent) { 21 | this.element = hasEvent; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/InteractionEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @Node 9 | public class InteractionEvent extends Event { 10 | 11 | @Relationship(type = "partners") 12 | private List partners; 13 | 14 | public InteractionEvent() { } 15 | 16 | public List getPartners() { 17 | return partners; 18 | } 19 | 20 | public void setPartners(List partners) { 21 | this.partners = partners; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/NegativeGeneExpressionRegulation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class NegativeGeneExpressionRegulation extends NegativeRegulation { 10 | 11 | public NegativeGeneExpressionRegulation() {} 12 | 13 | @ReactomeSchemaIgnore 14 | @Override 15 | @JsonIgnore 16 | public String getExplanation() { 17 | return "A negative gene expression regulation"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/PositiveGeneExpressionRegulation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class PositiveGeneExpressionRegulation extends PositiveRegulation { 10 | 11 | public PositiveGeneExpressionRegulation() {} 12 | 13 | @ReactomeSchemaIgnore 14 | @Override 15 | @JsonIgnore 16 | public String getExplanation() { 17 | return "A positive gene expression regulation"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/EventOf.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Pathway; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | @RelationshipProperties 8 | public class EventOf extends Has { 9 | 10 | @Override 11 | public String getType() { 12 | return "event"; 13 | } 14 | 15 | @JsonIgnore 16 | public Pathway getPathway() { 17 | return element; 18 | } 19 | 20 | public void setPathway(Pathway eventOf) { 21 | this.element = eventOf; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DrugActionType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @Node 9 | public class DrugActionType extends ReactionType { 10 | 11 | @Relationship(type = "instanceOf") 12 | private List instanceOf; 13 | 14 | public DrugActionType() { 15 | } 16 | 17 | public List getInstanceOf() { 18 | return instanceOf; 19 | } 20 | 21 | public void setInstanceOf(List instanceOf) { 22 | this.instanceOf = instanceOf; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/URL.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class URL extends Publication { 9 | 10 | @ReactomeProperty 11 | private String uniformResourceLocator; 12 | 13 | public URL() {} 14 | 15 | public String getUniformResourceLocator() { 16 | return this.uniformResourceLocator; 17 | } 18 | 19 | public void setUniformResourceLocator(String uniformResourceLocator) { 20 | this.uniformResourceLocator = uniformResourceLocator; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasEncapsulatedEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Event; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | @RelationshipProperties 8 | public class HasEncapsulatedEvent extends Has { 9 | @Override 10 | public String getType() { 11 | return "encapsulatedEvent"; 12 | } 13 | 14 | @JsonIgnore 15 | public Event getEvent() { 16 | return element; 17 | } 18 | 19 | public void setEvent(Event event) { 20 | this.element = event; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DefinedSet.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | /** 8 | * Two or more entities that are interchangeable in function. 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class DefinedSet extends EntitySet { 13 | 14 | public DefinedSet() {} 15 | 16 | @ReactomeSchemaIgnore 17 | @Override 18 | @JsonIgnore 19 | public String getExplanation() { 20 | return "Two or more entities that are interchangeable in function"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FragmentInsertionModification.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class FragmentInsertionModification extends FragmentModification { 9 | 10 | @ReactomeProperty 11 | private Integer coordinate; 12 | 13 | public FragmentInsertionModification() {} 14 | 15 | public Integer getCoordinate() { 16 | return coordinate; 17 | } 18 | 19 | public void setCoordinate(Integer coordinate) { 20 | this.coordinate = coordinate; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/ReactomeProperty.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * This annotation is used to mark primitive fields that should be filled during initial data import. 10 | * 11 | * @author Florian Korninger 12 | */ 13 | @Target({ElementType.FIELD, ElementType.METHOD}) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | public @interface ReactomeProperty { 16 | 17 | boolean addedField() default false; 18 | 19 | String originName() default ""; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Drug.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | @SuppressWarnings({"unused", "WeakerAccess"}) 7 | @Node 8 | public abstract class Drug extends PhysicalEntity { 9 | 10 | @Relationship(type = "referenceEntity") 11 | private ReferenceTherapeutic referenceEntity; 12 | 13 | public Drug() {} 14 | 15 | public ReferenceTherapeutic getReferenceEntity() { 16 | return referenceEntity; 17 | } 18 | 19 | public void setReferenceEntity(ReferenceTherapeutic referenceEntity) { 20 | this.referenceEntity = referenceEntity; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/TopLevelPathway.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | /** 6 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 7 | */ 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class TopLevelPathway extends Pathway { 11 | 12 | public TopLevelPathway() {} 13 | 14 | // The idea behind having this method was to avoid having this kind of object in the final schema 15 | // but at the end we figure out that is useful to have it, that is why this is commented out 16 | // @ReactomeSchemaIgnore 17 | // @Override 18 | // public String getSchemaClass() { 19 | // return Pathway.class.getSimpleName(); 20 | // } 21 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/CatalystActivityReference.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | @Node 7 | public class CatalystActivityReference extends ControlReference { 8 | 9 | @Relationship(type = "catalystActivity") 10 | private CatalystActivity catalystActivity; 11 | 12 | public CatalystActivityReference() { 13 | } 14 | 15 | public CatalystActivity getCatalystActivity() { 16 | return catalystActivity; 17 | } 18 | 19 | public void setCatalystActivity(CatalystActivity catalystActivity) { 20 | this.catalystActivity = catalystActivity; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/CustomQuery.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import org.neo4j.driver.Record; 4 | 5 | /** 6 | * When a custom class has to be mapped using Custom queries, the code expect this interface 7 | * to be implemented and that you provide your own way of mapping your class 8 | * 9 | * public CustomQuery build(Record r) { 10 | * this.setStId(r.get("stId").asString()); 11 | * this.setDisplayName(r.get("displayName").asString()); 12 | * this.setCustomReference(new CustomReference(r.get("customReference").get("database").asString(), r.get("customReference").get("identifier").asString())); 13 | * return this; 14 | * } 15 | * 16 | */ 17 | public interface CustomQuery { 18 | CustomQuery build(Record r); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FragmentReplacedModification.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class FragmentReplacedModification extends FragmentModification { 9 | 10 | @ReactomeProperty 11 | private String alteredAminoAcidFragment; 12 | 13 | public FragmentReplacedModification() {} 14 | 15 | public String getAlteredAminoAcidFragment() { 16 | return alteredAminoAcidFragment; 17 | } 18 | 19 | public void setAlteredAminoAcidFragment(String alteredAminoAcidFragment) { 20 | this.alteredAminoAcidFragment = alteredAminoAcidFragment; 21 | } 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ControlReference.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings({"unused", "WeakerAccess"}) 9 | @Node 10 | public abstract class ControlReference extends DatabaseObject { 11 | 12 | @Relationship(type = "literatureReference") 13 | private List literatureReference; 14 | 15 | public ControlReference() { 16 | } 17 | 18 | public List getLiteratureReference() { 19 | return literatureReference; 20 | } 21 | 22 | public void setLiteratureReference(List literatureReference) { 23 | this.literatureReference = literatureReference; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceRNASequence.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class ReferenceRNASequence extends ReferenceSequence { 11 | 12 | @Relationship(type = "referenceGene") 13 | private List referenceGene; 14 | 15 | public ReferenceRNASequence() { 16 | super(); 17 | } 18 | 19 | public List getReferenceGene() { 20 | return referenceGene; 21 | } 22 | 23 | public void setReferenceGene(List referenceGene) { 24 | this.referenceGene = referenceGene; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/InputForReactionLikeEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.ReactionLikeEvent; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * ConsumedBy -> bi-directionality for 9 | */ 10 | @RelationshipProperties 11 | public class InputForReactionLikeEvent extends Has { 12 | 13 | @Override 14 | public String getType() { 15 | return "inputOf"; 16 | } 17 | 18 | @JsonIgnore 19 | public ReactionLikeEvent getReactionLikeEvent() { 20 | return element; 21 | } 22 | 23 | public void setReactionLikeEvent(ReactionLikeEvent event) { 24 | this.element = event; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/EventProjectionWrapper.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * EventProjections is used to map a Collection of Events ancestors. 7 | * The original query prior to SDN6 was mapping the whole Pathway and only using 8 | * trivial attributes to be marshalled to JSON in the ContentService. 9 | */ 10 | public class EventProjectionWrapper { 11 | 12 | private Collection events; 13 | 14 | public EventProjectionWrapper(Collection events) { 15 | this.events = events; 16 | } 17 | 18 | public Collection getEvents() { 19 | return events; 20 | } 21 | 22 | public void setEvents(Collection events) { 23 | this.events = events; 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/GeneralRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.data.neo4j.core.Neo4jClient; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public class GeneralRepository { 9 | 10 | private final Neo4jClient neo4jClient; 11 | 12 | @Value("${spring.data.neo4j.database:graph.db}") 13 | private String databaseName; 14 | 15 | public GeneralRepository(Neo4jClient neo4jClient) { 16 | this.neo4jClient = neo4jClient; 17 | } 18 | 19 | public Boolean fitForService() { 20 | String query = "MATCH (n) RETURN COUNT(n) > 0 AS fitForService"; 21 | return neo4jClient.query(query).in(databaseName).fetchAs(Boolean.class).first().orElse(false); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/PositiveRegulation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | /** 8 | * This describes an Event/CatalystActivity that is positively regulated by the Regulator (e.g., allosteric activation). 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class PositiveRegulation extends Regulation { 13 | 14 | public PositiveRegulation() {} 15 | 16 | @ReactomeSchemaIgnore 17 | @Override 18 | @JsonIgnore 19 | public String getExplanation() { 20 | return "This describes an Event/CatalystActivity that is positively regulated by the Regulator (e.g., allosteric activation)"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasMember.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * HasMember is the relationship entity of EntitySets. It is needed to specify the order of members. 9 | */ 10 | @RelationshipProperties 11 | public class HasMember extends Has { 12 | @Override 13 | public String getType() { 14 | return "member"; 15 | } 16 | 17 | @JsonIgnore 18 | public PhysicalEntity getPhysicalEntity() { 19 | return element; 20 | } 21 | 22 | public void setPhysicalEntity(PhysicalEntity physicalEntity) { 23 | this.element = physicalEntity; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/Output.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * Output relationship of ReactionLikeEvent. It is needed to specify the stoichiometry and order of outputs. 9 | */ 10 | @RelationshipProperties 11 | public class Output extends Has { 12 | @Override 13 | public String getType() { 14 | return "output"; 15 | } 16 | 17 | @JsonIgnore 18 | public PhysicalEntity getPhysicalEntity() { 19 | return element; 20 | } 21 | 22 | public void setPhysicalEntity(PhysicalEntity physicalEntity) { 23 | this.element = physicalEntity; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/Input.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * Input relationship of ReactionLikeEvent. It is needed to specify the stoichiometry and order of inputs. 9 | */ 10 | @RelationshipProperties 11 | public class Input extends Has { 12 | 13 | @Override 14 | public String getType() { 15 | return "input"; 16 | } 17 | 18 | @JsonIgnore 19 | public PhysicalEntity getPhysicalEntity() { 20 | return element; 21 | } 22 | 23 | public void setPhysicalEntity(PhysicalEntity physicalEntity) { 24 | this.element = physicalEntity; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasCandidate.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * HasCandidate is the relationship entity of CandidateSets. It is needed to specify the order of members. 9 | */ 10 | @RelationshipProperties 11 | public class HasCandidate extends Has { 12 | @Override 13 | public String getType() { 14 | return "candidate"; 15 | } 16 | 17 | @JsonIgnore 18 | public PhysicalEntity getPhysicalEntity() { 19 | return element; 20 | } 21 | 22 | public void setPhysicalEntity(PhysicalEntity physicalEntity) { 23 | this.element = physicalEntity; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/AbstractModifiedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public abstract class AbstractModifiedResidue extends DatabaseObject { 9 | 10 | @Relationship(type = "referenceSequence") 11 | private ReferenceSequence referenceSequence; 12 | 13 | public AbstractModifiedResidue() {} 14 | 15 | public AbstractModifiedResidue(Long dbId) { 16 | super(dbId); 17 | } 18 | 19 | public ReferenceSequence getReferenceSequence() { 20 | return referenceSequence; 21 | } 22 | 23 | public void setReferenceSequence(ReferenceSequence referenceSequence) { 24 | this.referenceSequence = referenceSequence; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/AuthorPublication.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import org.reactome.server.graph.domain.model.Publication; 4 | import org.springframework.data.neo4j.core.schema.GeneratedValue; 5 | import org.springframework.data.neo4j.core.schema.Id; 6 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 7 | import org.springframework.data.neo4j.core.schema.TargetNode; 8 | 9 | import java.util.Objects; 10 | 11 | @RelationshipProperties 12 | public class AuthorPublication extends Has { 13 | @Override 14 | public String getType() { 15 | return "publication"; 16 | } 17 | 18 | public Publication getPublication() { 19 | return element; 20 | } 21 | 22 | public void setPublication(Publication publication) { 23 | this.element = publication; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Affiliation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class Affiliation extends DatabaseObject{ 11 | 12 | @ReactomeProperty 13 | private String address; 14 | @ReactomeProperty 15 | private List name; 16 | 17 | public Affiliation() {} 18 | 19 | public String getAddress() { 20 | return address; 21 | } 22 | 23 | public void setAddress(String address) { 24 | this.address = address; 25 | } 26 | 27 | public List getName() { 28 | return name; 29 | } 30 | 31 | public void setName(List name) { 32 | this.name = name; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/RepeatedUnitForPhysicalEntity.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Polymer; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * RepeatedUnit is the relationship entity of Polymer. It is needed to specify the stoichiometry (stoichiometry) of 9 | * repeatedUnits. 10 | */ 11 | @RelationshipProperties 12 | public class RepeatedUnitForPhysicalEntity extends Has { 13 | 14 | @Override 15 | public String getType() { 16 | return "repeatedUnitOf"; 17 | } 18 | 19 | @JsonIgnore 20 | public Polymer getPolymer() { 21 | return element; 22 | } 23 | 24 | public void setPolymer(Polymer polymer) { 25 | this.element = polymer; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/InteractorsCount.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import org.neo4j.driver.Record; 4 | 5 | public class InteractorsCount { 6 | 7 | public String acc; 8 | public Integer count; 9 | 10 | public String getAcc() { 11 | return acc; 12 | } 13 | 14 | public void setAcc(String acc) { 15 | this.acc = acc; 16 | } 17 | 18 | public Integer getCount() { 19 | return count; 20 | } 21 | 22 | public void setCount(Integer count) { 23 | this.count = count; 24 | } 25 | 26 | public static InteractorsCount build(Record record) { 27 | InteractorsCount interactorsCount = new InteractorsCount(); 28 | interactorsCount.setAcc(record.get("s").asString()); 29 | interactorsCount.setCount(record.get("t").asInt()); 30 | return interactorsCount; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/NegativeRegulation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | /** 8 | * This describes an Event/CatalystActivity that is negatively regulated by the Regulator (e.g., allosteric inhibition, competitive inhibition. 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class NegativeRegulation extends Regulation { 13 | 14 | public NegativeRegulation() {} 15 | 16 | @ReactomeSchemaIgnore 17 | @Override 18 | @JsonIgnore 19 | public String getExplanation() { 20 | return "This describes an Event/CatalystActivity that is negatively regulated by the Regulator (e.g., allosteric inhibition, competitive inhibition"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/DiseaseReaction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.ReactionLikeEvent; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * Output relationship of ReactionLikeEvent. It is needed to specify the stoichiometry and order of outputs. 9 | */ 10 | @RelationshipProperties 11 | public class DiseaseReaction extends Has { 12 | @Override 13 | public String getType() { 14 | return "diseaseReaction"; 15 | } 16 | 17 | @JsonIgnore 18 | public ReactionLikeEvent getDiseaseReaction() { 19 | return element; 20 | } 21 | 22 | public void setDiseaseReaction(ReactionLikeEvent reactionLikeEvent) { 23 | this.element = reactionLikeEvent; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/RepeatedUnit.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * RepeatedUnit is the relationship entity of Polymer. It is needed to specify the stoichiometry (stoichiometry) of 9 | * repeatedUnits. 10 | */ 11 | @RelationshipProperties 12 | public class RepeatedUnit extends Has { 13 | @Override 14 | public String getType() { 15 | return "repeatedUnit"; 16 | } 17 | 18 | @JsonIgnore 19 | public PhysicalEntity getPhysicalEntity() { 20 | return element; 21 | } 22 | 23 | public void setPhysicalEntity(PhysicalEntity physicalEntity) { 24 | this.element = physicalEntity; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/PublicationAuthor.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Person; 5 | import org.springframework.data.neo4j.core.schema.GeneratedValue; 6 | import org.springframework.data.neo4j.core.schema.Id; 7 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 8 | import org.springframework.data.neo4j.core.schema.TargetNode; 9 | 10 | import java.util.Objects; 11 | 12 | @RelationshipProperties 13 | public class PublicationAuthor extends Has { 14 | @Override 15 | public String getType() { 16 | return "author"; 17 | } 18 | 19 | @JsonIgnore 20 | public Person getAuthor() { 21 | return element; 22 | } 23 | 24 | public void setAuthor(Person author) { 25 | this.element = author; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DrugType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class DrugType extends DatabaseObject { 11 | 12 | @ReactomeProperty 13 | private String definition; 14 | 15 | @ReactomeProperty 16 | private List name; 17 | 18 | public DrugType() { 19 | } 20 | 21 | public List getName() { 22 | return name; 23 | } 24 | 25 | public void setName(List name) { 26 | this.name = name; 27 | } 28 | 29 | public String getDefinition() { 30 | return definition; 31 | } 32 | 33 | public void setDefinition(String definition) { 34 | this.definition = definition; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/OutputForReactionLikeEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.ReactionLikeEvent; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * Output relationship of ReactionLikeEvent. It is needed to specify the stoichiometry and order of outputs. 9 | */ 10 | @RelationshipProperties 11 | public class OutputForReactionLikeEvent extends Has { 12 | @Override 13 | public String getType() { 14 | return "outputOf"; 15 | } 16 | 17 | @JsonIgnore 18 | public ReactionLikeEvent getReactionLikeEvent() { 19 | return element; 20 | } 21 | 22 | public void setReactionLikeEvent(ReactionLikeEvent reactionLikeEvent) { 23 | this.element = reactionLikeEvent; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ControlledVocabulary.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | import java.util.List; 7 | 8 | @Node 9 | public abstract class ControlledVocabulary extends DatabaseObject { 10 | 11 | @ReactomeProperty 12 | private String definition; 13 | 14 | @ReactomeProperty 15 | private List name; 16 | 17 | public ControlledVocabulary() { 18 | } 19 | 20 | public String getDefinition() { 21 | return definition; 22 | } 23 | 24 | public void setDefinition(String definition) { 25 | this.definition = definition; 26 | } 27 | 28 | public List getName() { 29 | return name; 30 | } 31 | 32 | public void setName(List name) { 33 | this.name = name; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DBInfo.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | 5 | @Node 6 | public class DBInfo extends Release { 7 | 8 | private String name; 9 | private Long checksum; 10 | 11 | /** 12 | * @deprecated 13 | * Use {@link Release#getReleaseNumber()} instead 14 | * @return Database version 15 | */ 16 | @Deprecated 17 | public Integer getVersion() { 18 | return this.getReleaseNumber(); 19 | } 20 | 21 | public DBInfo() { 22 | } 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | 33 | public Long getChecksum() { 34 | return checksum; 35 | } 36 | 37 | public void setChecksum(Long checksum) { 38 | this.checksum = checksum; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasComponent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * HasComponent is the relationship entity of Complexes. It is needed to specify the stoichiometry and order of 9 | * components. 10 | */ 11 | @SuppressWarnings("unused") 12 | @RelationshipProperties 13 | public class HasComponent extends Has { 14 | 15 | @Override 16 | public String getType() { 17 | return "component"; 18 | } 19 | 20 | @JsonIgnore 21 | public PhysicalEntity getPhysicalEntity() { 22 | return element; 23 | } 24 | 25 | public void setPhysicalEntity(PhysicalEntity physicalEntity) { 26 | this.element = physicalEntity; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FunctionalStatusType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class FunctionalStatusType extends DatabaseObject { 11 | 12 | @ReactomeProperty 13 | private String definition; 14 | @ReactomeProperty 15 | private List name; 16 | 17 | public FunctionalStatusType() {} 18 | 19 | public String getDefinition() { 20 | return definition; 21 | } 22 | 23 | public void setDefinition(String definition) { 24 | this.definition = definition; 25 | } 26 | 27 | public List getName() { 28 | return name; 29 | } 30 | 31 | public void setName(List name) { 32 | this.name = name; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/ComponentOf.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Complex; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * ComponentOf is the incoming relationship for HasComponent (SDN6) is the relationship entity of Complexes. 9 | * It is needed to specify the stoichiometry and order of 10 | * components. 11 | */ 12 | @SuppressWarnings("unused") 13 | @RelationshipProperties 14 | public class ComponentOf extends Has { 15 | 16 | @Override 17 | public String getType() { 18 | return "componentOf"; 19 | } 20 | 21 | @JsonIgnore 22 | public Complex getComplex() { 23 | return element; 24 | } 25 | 26 | public void setComplex(Complex complex) { 27 | this.element = complex; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasCompartment.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Compartment; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * HasCompartment is the relationship compartment of Event and PhysicalEntity. 9 | * 10 | * It is basically needed to specify the order of compartments. 11 | */ 12 | @SuppressWarnings("unused") 13 | @RelationshipProperties 14 | public class HasCompartment extends Has { 15 | 16 | @Override 17 | public String getType() { 18 | return "compartment"; 19 | } 20 | 21 | @JsonIgnore 22 | public Compartment getCompartment() { 23 | return element; 24 | } 25 | 26 | public void setCompartment(Compartment compartment) { 27 | this.element = compartment; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Polymerisation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | /** 8 | * Reactions that follow the pattern: Polymer + Unit - Polymer (there may be a catalyst involved). Used to describe the mechanistic detail of a polymerisation 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class Polymerisation extends ReactionLikeEvent { 13 | 14 | public Polymerisation() {} 15 | 16 | @ReactomeSchemaIgnore 17 | @Override 18 | @JsonIgnore 19 | public String getExplanation() { 20 | return "Reactions that follow the pattern: Polymer + Unit -> Polymer (there may be a catalyst involved). " + 21 | "Used to describe the mechanistic detail of a polymerisation"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/UndirectedInteraction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * The name of the has been taken from Cytoscape. 10 | * 11 | * Undirected interactions has a list of ReferenceEntity instances that MUST contain only 2 elements. 12 | * 13 | */ 14 | @SuppressWarnings("unused") 15 | @Node 16 | public class UndirectedInteraction extends Interaction { 17 | 18 | @Relationship(type = "interactor") 19 | private List interactor; 20 | 21 | public UndirectedInteraction() { } 22 | 23 | public List getInteractor() { 24 | return interactor; 25 | } 26 | 27 | public void setInteractor(List interactor) { 28 | this.interactor = interactor; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/DoiService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.result.DoiPathwayDTO; 4 | import org.reactome.server.graph.repository.DoiRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Collection; 9 | 10 | @Service 11 | public class DoiService { 12 | 13 | private DoiRepository doiRepository; 14 | 15 | @Autowired 16 | public void setDoiRepository(DoiRepository doiRepository) { 17 | this.doiRepository = doiRepository; 18 | } 19 | 20 | /** 21 | * Retrieve all pathways which the doi value is not null, and all the authors, reviewers, editors are 22 | * related to this pathway, sub pathway and reactions. 23 | */ 24 | public Collection getAllDoiPathway() { 25 | return doiRepository.doiPathwayDTO(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/MarkerReference.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @Node 9 | public class MarkerReference extends ControlReference { 10 | 11 | @Relationship(type = "marker") 12 | private EntityWithAccessionedSequence marker; 13 | 14 | @Relationship(type = "cell") 15 | private List cell; 16 | 17 | public MarkerReference() { 18 | } 19 | 20 | public EntityWithAccessionedSequence getMarker() { 21 | return marker; 22 | } 23 | 24 | public void setMarker(EntityWithAccessionedSequence marker) { 25 | this.marker = marker; 26 | } 27 | 28 | public List getCell() { 29 | return cell; 30 | } 31 | 32 | public void setCell(List cell) { 33 | this.cell = cell; 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/ReferenceEntityService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.model.ReferenceEntity; 4 | import org.reactome.server.graph.repository.ReferenceEntityRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Collection; 9 | 10 | @SuppressWarnings("unused") 11 | @Service 12 | public class ReferenceEntityService { 13 | 14 | private final ReferenceEntityRepository referenceEntityRepository; 15 | 16 | @Autowired 17 | public ReferenceEntityService(ReferenceEntityRepository referenceEntityRepository) { 18 | this.referenceEntityRepository = referenceEntityRepository; 19 | } 20 | 21 | public Collection getReferenceEntitiesFor(String identifier){ 22 | return referenceEntityRepository.getReferenceEntitiesFor(identifier); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/ReactomeRelationship.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * This annotation is used to mark relationships added to improve graph traversing. Those 10 | * relationship using this annotation do not exist in the original relational database. In that case, addedField should be true. 11 | * 12 | * It is also used to tell the name of the relationship in GKCentral using originName. 13 | * 14 | * This is currently used for data consistency check in the https://github.com/reactome/graph-importer 15 | * 16 | */ 17 | @Target({ElementType.FIELD, ElementType.METHOD}) 18 | @Retention(RetentionPolicy.RUNTIME) 19 | public @interface ReactomeRelationship { 20 | boolean addedField() default false; 21 | String originName() default ""; 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/annotations/ReactomeTransient.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * This annotation is used to mark all fields that should not be persisted during initial data import, but will be 10 | * used by the graph database later on. 11 | * This is done to avoid duplicated relationships. Example: inferred_to will create the initial relationship 12 | * inferredFrom will be annotated @ReactomeTransient to avoid creating the same relationship. Inferred_from will 13 | * reuse INCOMING the inferred_to relationship. 14 | * 15 | * Created by: 16 | * 17 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 18 | * @since 01.03.16. 19 | */ 20 | @Target({ElementType.FIELD, ElementType.METHOD}) 21 | @Retention(RetentionPolicy.RUNTIME) 22 | public @interface ReactomeTransient {} -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GroupModifiedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeAllowedClasses; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class GroupModifiedResidue extends TranslationalModification { 10 | 11 | @Relationship(type = "modification") 12 | @ReactomeAllowedClasses(allowed = {EntitySet.class, Polymer.class, ReferenceGroup.class}) 13 | private DatabaseObject modification; 14 | 15 | public GroupModifiedResidue() {} 16 | 17 | @ReactomeAllowedClasses(allowed = {EntitySet.class, Polymer.class, ReferenceGroup.class}) 18 | public DatabaseObject getModification() { 19 | return modification; 20 | } 21 | 22 | public void setModification(DatabaseObject modification) { 23 | this.modification = modification; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/MemberOf.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.Complex; 5 | import org.reactome.server.graph.domain.model.EntitySet; 6 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 7 | 8 | /** 9 | * ComponentOf is the incoming relationship for HasComponent (SDN6) is the relationship entity of Complexes. 10 | * It is needed to specify the stoichiometry and order of 11 | * components. 12 | */ 13 | @SuppressWarnings("unused") 14 | @RelationshipProperties 15 | public class MemberOf extends Has { 16 | 17 | @Override 18 | public String getType() { 19 | return "memberOf"; 20 | } 21 | 22 | @JsonIgnore 23 | public EntitySet getEntitySet() { 24 | return element; 25 | } 26 | 27 | public void getEntitySet(EntitySet entitySet) { 28 | element = entitySet; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/DeletedInstanceService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.model.DeletedInstance; 4 | import org.reactome.server.graph.repository.DeletedInstanceRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | @Service 12 | public class DeletedInstanceService { 13 | 14 | private DeletedInstanceRepository repository; 15 | 16 | @Autowired 17 | public DeletedInstanceService(DeletedInstanceRepository repository) { 18 | this.repository = repository; 19 | } 20 | 21 | public Optional getDeletedInstanceByDbId(Long dbId) { 22 | return this.repository.getDeletedInstanceByDbId(dbId); 23 | } 24 | 25 | public List getByDeletedDbId(Long dbId) { 26 | return this.repository.getByDeletedDbId(dbId); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/custom/CustomReference.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.custom; 2 | 3 | /** 4 | * POJO for testing the Custom Cypher Queries 5 | * 6 | * @author Guilherme S Viteri 7 | */ 8 | @SuppressWarnings("unused") 9 | public class CustomReference { 10 | private String database; 11 | private String identifier; 12 | 13 | public CustomReference(String database, String identifier) { 14 | this.database = database; 15 | this.identifier = identifier; 16 | } 17 | 18 | public String getDatabase() { 19 | return database; 20 | } 21 | 22 | // Commented out in purpose so the marshaller uses the field -> FOR TEST PURPOSES! 23 | // public void setDatabase(String database) { 24 | // this.database = database; 25 | // } 26 | 27 | public String getIdentifier() { 28 | return identifier; 29 | } 30 | 31 | public void setIdentifier(String identifier) { 32 | this.identifier = identifier; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/CellLineagePath.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | import org.springframework.data.neo4j.core.schema.Relationship; 7 | 8 | @Node 9 | public class CellLineagePath extends Pathway { 10 | 11 | @Relationship(type = "tissue") 12 | private Anatomy tissue; 13 | 14 | public CellLineagePath() { 15 | } 16 | 17 | public Anatomy getTissue() { 18 | return tissue; 19 | } 20 | 21 | public void setTissue(Anatomy tissue) { 22 | this.tissue = tissue; 23 | } 24 | 25 | @ReactomeSchemaIgnore 26 | @Override 27 | @JsonIgnore 28 | public String getExplanation() { 29 | return "A collection of related Events. These events are mostly CellDevelopmentStep. This is used to describe tissues and cell differentiation "; 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/TocService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.result.TocPathwayDTO; 4 | import org.reactome.server.graph.repository.TocRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Collection; 9 | 10 | @Service 11 | public class TocService { 12 | 13 | private TocRepository tocRepository; 14 | 15 | @Autowired 16 | public void setTocRepository(TocRepository tocRepository) { 17 | this.tocRepository = tocRepository; 18 | } 19 | 20 | /** 21 | * Retrieve all top level pathways and the first hierarchy sub pathways, fetch all the authors, reviewers, editors are 22 | * related to this pathway, sub pathway and reactions. 23 | * Note: authors contains revised person 24 | */ 25 | public Collection getAllTocPathway() { 26 | return tocRepository.getTocPathways(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/CandidateOf.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.CandidateSet; 5 | import org.reactome.server.graph.domain.model.Complex; 6 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 7 | 8 | /** 9 | * ComponentOf is the incoming relationship for HasComponent (SDN6) is the relationship entity of Complexes. 10 | * It is needed to specify the stoichiometry and order of 11 | * components. 12 | */ 13 | @SuppressWarnings("unused") 14 | @RelationshipProperties 15 | public class CandidateOf extends Has { 16 | 17 | @Override 18 | public String getType() { 19 | return "candidateOf"; 20 | } 21 | 22 | @JsonIgnore 23 | public CandidateSet getCandidateSet() { 24 | return element; 25 | } 26 | 27 | public void setCandidateSet(CandidateSet candidateSet) { 28 | this.element = candidateSet; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ModifiedNucleotide.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | @Node 8 | public class ModifiedNucleotide extends TranscriptionalModification { 9 | 10 | @ReactomeProperty 11 | private Integer coordinate; 12 | 13 | @Relationship(type = "modification") 14 | private DatabaseObject modification; 15 | 16 | public ModifiedNucleotide() { 17 | } 18 | 19 | public Integer getCoordinate() { 20 | return coordinate; 21 | } 22 | 23 | public void setCoordinate(Integer coordinate) { 24 | this.coordinate = coordinate; 25 | } 26 | 27 | public DatabaseObject getModification() { 28 | return modification; 29 | } 30 | 31 | public void setModification(DatabaseObject modification) { 32 | this.modification = modification; 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReplacedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class ReplacedResidue extends GeneticallyModifiedResidue { 12 | 13 | @ReactomeProperty 14 | private Integer coordinate; 15 | 16 | @Relationship(type = "psiMod") 17 | private List psiMod; 18 | 19 | public ReplacedResidue() {} 20 | 21 | public Integer getCoordinate() { 22 | return coordinate; 23 | } 24 | 25 | public void setCoordinate(Integer coordinate) { 26 | this.coordinate = coordinate; 27 | } 28 | 29 | public List getPsiMod() { 30 | return psiMod; 31 | } 32 | 33 | public void setPsiMod(List psiMod) { 34 | this.psiMod = psiMod; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/schema/SchemaDataDownload.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.schema; 2 | 3 | import com.fasterxml.jackson.annotation.JsonGetter; 4 | import org.reactome.server.graph.domain.model.Event; 5 | 6 | @SuppressWarnings("unused") 7 | public class SchemaDataDownload { 8 | private final String contentUrl; 9 | private final String fileFormat; 10 | private final String encodingFormat = "UTF-8"; 11 | 12 | public SchemaDataDownload(SchemaDataDownloadType dataDownloadType, Event event) { 13 | this.contentUrl = dataDownloadType.getUrl(event.getDbId()); 14 | this.fileFormat = dataDownloadType.getFormat(); 15 | } 16 | 17 | public String getContentUrl() { 18 | return contentUrl; 19 | } 20 | 21 | public String getFileFormat() { 22 | return fileFormat; 23 | } 24 | 25 | public String getEncodingFormat() { 26 | return encodingFormat; 27 | } 28 | 29 | @JsonGetter(value = "@type") 30 | public String getType(){ 31 | return "DataDownload"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/DeletedService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | 4 | import org.reactome.server.graph.domain.model.*; 5 | import org.reactome.server.graph.repository.DeletedRepository; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.List; 10 | import java.util.Optional; 11 | 12 | @Service 13 | public class DeletedService { 14 | 15 | private DeletedRepository repository; 16 | 17 | @Autowired 18 | public DeletedService(DeletedRepository repository) { 19 | this.repository = repository; 20 | } 21 | 22 | public Optional getDeletedByDbId(Long dbId) { 23 | return this.repository.getDeletedByDbId(dbId); 24 | } 25 | 26 | public List getByDeletedInstanceDbId(Long dbId) { 27 | return this.repository.getByDeletedInstanceDbId(dbId); 28 | } 29 | 30 | public List getByReplacementStId(String stId) { 31 | return this.repository.getByReplacementStId(stId); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /update_major_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PACKAGE_NAME="GRAPH_CORE_VERSION" 4 | 5 | # Check if VERSIONS_FILE_PATH is set 6 | if [ -z "${VERSIONS_FILE_PATH}" ]; then 7 | echo "Error: Please define \${VERSIONS_FILE_PATH} in the GO-CD environment or in the server." 8 | exit 1 9 | fi 10 | 11 | # Check if VERSIONS_FILE_PATH exists 12 | if [ ! -f "${VERSIONS_FILE_PATH}" ]; then 13 | echo "Error: File ${VERSIONS_FILE_PATH} not found." 14 | exit 1 15 | fi 16 | 17 | # Load versions to be used 18 | # shellcheck source="${VERSIONS_FILE_PATH}" 19 | source "${VERSIONS_FILE_PATH}" 20 | 21 | #add parents version and current version 22 | xmlstarlet ed -L \ 23 | -u "//_:project/_:parent/_:version" -v "${REACTOME_PARENT_VERSION}" \ 24 | -u "//_:project/_:version" -v "${!PACKAGE_NAME}" \ 25 | "pom.xml" 26 | 27 | echo "Maven ${PACKAGE_NAME} updated to ${!PACKAGE_NAME}" 28 | echo "Maven parent updated to ${REACTOME_PARENT_VERSION}" 29 | 30 | 31 | # deleting custom versions of org.reactome.server 32 | xmlstarlet ed -L -d "//_:dependency[_:groupId[starts-with(text(),'org.reactome')]]/_:version" pom.xml 33 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/HasModifiedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.model.AbstractModifiedResidue; 5 | import org.springframework.data.neo4j.core.schema.RelationshipProperties; 6 | 7 | /** 8 | * HasModifiedResidue is the relationship hasModifiedResidue of EntityWithAccessionedSequence. 9 | * It is needed to specify the stoichiometry and order of AbstractModifiedResidue instances. 10 | */ 11 | @SuppressWarnings("unused") 12 | @RelationshipProperties 13 | public class HasModifiedResidue extends Has { 14 | 15 | @Override 16 | public String getType() { 17 | return "modifiedResidue"; 18 | } 19 | 20 | @JsonIgnore 21 | public AbstractModifiedResidue getAbstractModifiedResidue() { 22 | return element; 23 | } 24 | 25 | public void setAbstractModifiedResidue(AbstractModifiedResidue abstractModifiedResidue) { 26 | this.element = abstractModifiedResidue; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Summation.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class Summation extends DatabaseObject { 12 | 13 | @ReactomeProperty 14 | private String text; 15 | 16 | @Relationship(type = "literatureReference") 17 | private List literatureReference; 18 | 19 | public Summation() {} 20 | 21 | public String getText() { 22 | return this.text; 23 | } 24 | 25 | public void setText(String text) { 26 | this.text = text; 27 | } 28 | 29 | public List getLiteratureReference() { 30 | return literatureReference; 31 | } 32 | 33 | public void setLiteratureReference(List literatureReference) { 34 | this.literatureReference = literatureReference; 35 | } 36 | 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/DeletedInstanceRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.DeletedInstance; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | import java.util.Optional; 11 | 12 | @Repository 13 | public interface DeletedInstanceRepository extends Neo4jRepository { 14 | //language=cypher 15 | @Query(" MATCH (d:DeletedInstance{dbId:$dbId}) " + 16 | "OPTIONAL MATCH (d)-[r]-(m) " + 17 | "RETURN d, collect(r), collect(m)") 18 | Optional getDeletedInstanceByDbId(@Param("dbId") Long dbId); 19 | 20 | 21 | @Query("MATCH (d:DeletedInstance)<-[:deletedInstance]-(de:Deleted) " + 22 | "where de.dbId = $dbId " + 23 | "return d ") 24 | List getByDeletedDbId(@Param("dbId") Long dbId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/PublicationRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.Publication; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | 11 | @Repository 12 | public interface PublicationRepository extends Neo4jRepository { 13 | 14 | @Query("MATCH (:Person{orcidId:$orcidId})-[:author]-(pub:Publication) RETURN pub") 15 | Collection getPublicationsOfPersonByOrcidId(@Param("orcidId") String orcidId); 16 | 17 | @Query("MATCH (:Person{dbId:$dbId})-[:author]-(pub:Publication) RETURN pub") 18 | Collection getPublicationsOfPersonByDbId(@Param("dbId") Long dbId); 19 | 20 | @Query("MATCH (:Person{eMailAddress:$email})-[:author]-(pub:Publication) RETURN pub") 21 | Collection getPublicationsOfPersonByEmail(@Param("email") String email); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/Referrals.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import org.neo4j.driver.Record; 4 | 5 | import java.util.List; 6 | 7 | @SuppressWarnings("unused") 8 | public class Referrals { 9 | 10 | private String referral; 11 | private List objects; 12 | 13 | public Referrals() { 14 | } 15 | 16 | public Referrals(String referral, List objects) { 17 | this.referral = referral; 18 | this.objects = objects; 19 | } 20 | 21 | public static Referrals build(Record record) { 22 | return new Referrals(record.get("referral").asString(), record.get("objects").asList(SimpleDatabaseObject::build)); 23 | } 24 | 25 | public String getReferral() { 26 | return referral; 27 | } 28 | 29 | public void setReferral(String referral) { 30 | this.referral = referral; 31 | } 32 | 33 | public List getObjects() { 34 | return objects; 35 | } 36 | 37 | public void setObjects(List objects) { 38 | this.objects = objects; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FunctionalStatus.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class FunctionalStatus extends DatabaseObject { 9 | 10 | @Relationship(type = "functionalStatusType") 11 | private FunctionalStatusType functionalStatusType; 12 | 13 | @Relationship(type = "structuralVariant") 14 | private SequenceOntology structuralVariant; 15 | 16 | public FunctionalStatus() {} 17 | 18 | public FunctionalStatusType getFunctionalStatusType() { 19 | return functionalStatusType; 20 | } 21 | 22 | public void setFunctionalStatusType(FunctionalStatusType functionalStatusType) { 23 | this.functionalStatusType = functionalStatusType; 24 | } 25 | 26 | public SequenceOntology getStructuralVariant() { 27 | return structuralVariant; 28 | } 29 | 30 | public void setStructuralVariant(SequenceOntology structuralVariant) { 31 | this.structuralVariant = structuralVariant; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceMolecule.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 6 | import org.springframework.data.neo4j.core.schema.Node; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class ReferenceMolecule extends ReferenceEntity { 11 | 12 | @ReactomeProperty 13 | private String formula; 14 | 15 | @ReactomeProperty(addedField = true) 16 | private Boolean trivial; 17 | 18 | public ReferenceMolecule() { 19 | super(); 20 | this.setMoleculeType("Chemical"); 21 | } 22 | 23 | public String getFormula() { 24 | return formula; 25 | } 26 | 27 | public void setFormula(String formula) { 28 | this.formula = formula; 29 | } 30 | 31 | @JsonIgnore 32 | @ReactomeSchemaIgnore 33 | public Boolean getTrivial() { 34 | return trivial; 35 | } 36 | 37 | public void setTrivial(Boolean trivial) { 38 | this.trivial = trivial; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/UpdateTrackerService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.model.UpdateTracker; 4 | import org.reactome.server.graph.repository.UpdateTrackerRepository; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | @Service 12 | public class UpdateTrackerService { 13 | 14 | private UpdateTrackerRepository repository; 15 | 16 | @Autowired 17 | public UpdateTrackerService(UpdateTrackerRepository repository) { 18 | this.repository = repository; 19 | } 20 | 21 | 22 | public Optional findUpdateTrackerByDbId(Long dbId) { 23 | return this.repository.findUpdateTrackerByDbId(dbId); 24 | } 25 | 26 | public List findByUpdatedInstanceDbId(Long dbId) { 27 | return this.repository.findByUpdatedInstanceDbId(dbId); 28 | } 29 | 30 | public List findByUpdatedInstanceStId(String stId) { 31 | return this.repository.findByUpdatedInstanceStId(stId); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/relationship/CompositionAggregator.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.relationship; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonView; 5 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 6 | import org.reactome.server.graph.domain.annotations.StoichiometryView; 7 | import org.reactome.server.graph.domain.model.DatabaseObject; 8 | 9 | import java.util.Collection; 10 | import java.util.List; 11 | import java.util.Objects; 12 | import java.util.stream.Collectors; 13 | import java.util.stream.Stream; 14 | 15 | public interface CompositionAggregator { 16 | 17 | 18 | @JsonIgnore 19 | Stream>> defineCompositionRelations(); 20 | 21 | @JsonView(StoichiometryView.NestedAggregated.class) 22 | @ReactomeSchemaIgnore 23 | default List> getComposedOf() { 24 | return defineCompositionRelations() 25 | .filter(Objects::nonNull) 26 | .flatMap(Collection::stream) 27 | .collect(Collectors.toList()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/OtherEntity.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | /** 8 | * Entities that we are unable or unwilling to describe in chemical detail and cannot be put in any other class. Can be used to represent complex structures in the cell that take part in a reaction but which we cannot or do not want to define molecularly, e.g. cell membrane, 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class OtherEntity extends PhysicalEntity { 13 | 14 | public OtherEntity() {} 15 | 16 | @ReactomeSchemaIgnore 17 | @Override 18 | @JsonIgnore 19 | public String getExplanation() { 20 | return "Entities that we are unable or unwilling to describe in chemical detail and cannot be put in any other class. " + 21 | "Can be used to represent complex structures in the cell that take part in a reaction but which we cannot or do not want to define molecularly, e.g. cell membrane, Holliday structure"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/DoiServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.reactome.server.graph.domain.result.DoiPathwayDTO; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | import java.util.Collection; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | 13 | @SpringBootTest 14 | public class DoiServiceTest extends BaseTest { 15 | 16 | @Autowired 17 | public DoiService doiService; 18 | 19 | @Test 20 | public void testAllDoiPathway(){ 21 | logger.info("Started testing DoiServiceTest.testAllDoiPathway"); 22 | long start, time; 23 | start = System.currentTimeMillis(); 24 | Collection dois = doiService.getAllDoiPathway(); 25 | time = System.currentTimeMillis() - start; 26 | logger.info("GraphDb execution time: " + time + "ms"); 27 | assertNotNull(dois); 28 | assertTrue(dois.size() > 15); 29 | logger.info("Finished"); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/TocServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.reactome.server.graph.domain.result.TocPathwayDTO; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | import java.util.Collection; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | 13 | @SpringBootTest 14 | public class TocServiceTest extends BaseTest { 15 | 16 | @Autowired 17 | public TocService tocService; 18 | 19 | @Test 20 | public void testAllTocPathway(){ 21 | logger.info("Started testing TocServiceTest.testAllTocPathway"); 22 | long start, time; 23 | start = System.currentTimeMillis(); 24 | Collection tocs = tocService.getAllTocPathway(); 25 | time = System.currentTimeMillis() - start; 26 | logger.info("GraphDb execution time: " + time + "ms"); 27 | 28 | assertNotNull(tocs); 29 | assertTrue(tocs.size() > 15); 30 | logger.info("Finished"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/SpeciesRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.Species; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public interface SpeciesRepository extends Neo4jRepository { 13 | 14 | @Query("MATCH (n:Species)<-[:species]-(:TopLevelPathway) RETURN DISTINCT n ORDER BY n.displayName") 15 | List getSpecies(); 16 | 17 | @Query("MATCH (n:Species) RETURN n ORDER BY n.displayName") 18 | List getAllSpecies(); 19 | 20 | @Query("MATCH (n:Species{taxId:$taxId}) RETURN n") 21 | Species getSpeciesByTaxId(@Param("taxId") String taxId); 22 | 23 | @Query("MATCH (n:Species{dbId:$dbId}) RETURN n") 24 | Species getSpeciesByDbId(@Param("dbId") Long dbId); 25 | 26 | @Query("MATCH (n:Species) WHERE $name IN n.name RETURN n") 27 | Species getSpeciesByName(@Param("name") String name); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DirectedInteraction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | /** 7 | * The name of the has been taken from Cytoscape. 8 | * 9 | * Directed interactions has two properties holding a ReferenceEntity instance each. The interaction is 10 | * 11 | * (source) -[interacts]-> (target) 12 | * 13 | */ 14 | @SuppressWarnings("unused") 15 | @Node 16 | public class DirectedInteraction extends Interaction { 17 | 18 | @Relationship(type = "source") 19 | private ReferenceEntity source; 20 | 21 | @Relationship(type = "target") 22 | private ReferenceEntity target; 23 | 24 | public DirectedInteraction() { } 25 | 26 | public ReferenceEntity getSource() { 27 | return source; 28 | } 29 | 30 | public void setSource(ReferenceEntity source) { 31 | this.source = source; 32 | } 33 | 34 | public ReferenceEntity getTarget() { 35 | return target; 36 | } 37 | 38 | public void setTarget(ReferenceEntity target) { 39 | this.target = target; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceIsoform.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class ReferenceIsoform extends ReferenceGeneProduct { 12 | 13 | @ReactomeProperty 14 | private String variantIdentifier; 15 | 16 | @Relationship(type = "isoformParent") 17 | private List isoformParent; 18 | 19 | public ReferenceIsoform() { 20 | super(); 21 | } 22 | 23 | public String getVariantIdentifier() { 24 | return this.variantIdentifier; 25 | } 26 | 27 | public void setVariantIdentifier(String variantIdentifier) { 28 | this.variantIdentifier = variantIdentifier; 29 | } 30 | 31 | public List getIsoformParent() { 32 | return isoformParent; 33 | } 34 | 35 | public void setIsoformParent(List isoformParent) { 36 | this.isoformParent = isoformParent; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/Main.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph; 2 | 3 | import org.aspectj.lang.Aspects; 4 | import org.reactome.server.graph.aop.LazyFetchAspect; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.aspectj.EnableSpringConfigured; 9 | import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | @EnableNeo4jRepositories(basePackages = "org.reactome.server.graph.repository") 13 | @EnableTransactionManagement 14 | @EnableSpringConfigured 15 | @SpringBootApplication 16 | public class Main { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(Main.class, args); 20 | } 21 | 22 | /** 23 | * This is needed to get hold of the instance of the aspect which is created outside of the spring container, 24 | * and make it available for autowiring. 25 | */ 26 | @Bean LazyFetchAspect lazyFetchAspect() { 27 | return Aspects.aspectOf(LazyFetchAspect.class); 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Release.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 6 | import org.springframework.data.neo4j.core.schema.Node; 7 | 8 | @Node 9 | public class Release extends MetaDatabaseObject { 10 | 11 | @ReactomeProperty 12 | private String releaseDate; 13 | 14 | @ReactomeProperty 15 | private Integer releaseNumber; 16 | 17 | public Release() { 18 | } 19 | 20 | public String getReleaseDate() { 21 | return releaseDate; 22 | } 23 | 24 | public void setReleaseDate(String releaseDate) { 25 | this.releaseDate = releaseDate; 26 | } 27 | 28 | public Integer getReleaseNumber() { 29 | return releaseNumber; 30 | } 31 | 32 | public void setReleaseNumber(Integer releaseNumber) { 33 | this.releaseNumber = releaseNumber; 34 | } 35 | 36 | @ReactomeSchemaIgnore 37 | @Override 38 | @JsonIgnore 39 | public String getExplanation() { 40 | // todo 41 | return "Release details"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/HierarchyWrapper.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * HierarchyWrapper is projecting a giving DatabaseObject and its give Pathway Hierarchy Tree. 7 | * The reasons for a Collection of Collection is that the result comes as Path toward the TopLevelPathway 8 | * and many instances are present in more the one branch or a tree e.g. Proteins. 9 | */ 10 | public class HierarchyWrapper { 11 | 12 | private HierarchyTreeItem root; 13 | private Collection> nodes; 14 | 15 | public HierarchyWrapper(HierarchyTreeItem root, Collection> nodes) { 16 | this.root = root; 17 | this.nodes = nodes; 18 | } 19 | 20 | public HierarchyTreeItem getRoot() { 21 | return root; 22 | } 23 | 24 | public void setRoot(HierarchyTreeItem databaseObject) { 25 | this.root = root; 26 | } 27 | 28 | public Collection> getNodes() { 29 | return nodes; 30 | } 31 | 32 | public void setNodes(Collection> nodes) { 33 | this.nodes = nodes; 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FragmentModification.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public abstract class FragmentModification extends GeneticallyModifiedResidue { 9 | 10 | @ReactomeProperty 11 | private Integer endPositionInReferenceSequence; 12 | @ReactomeProperty 13 | private Integer startPositionInReferenceSequence; 14 | 15 | public FragmentModification() {} 16 | 17 | public Integer getEndPositionInReferenceSequence() { 18 | return endPositionInReferenceSequence; 19 | } 20 | 21 | public void setEndPositionInReferenceSequence(Integer endPositionInReferenceSequence) { 22 | this.endPositionInReferenceSequence = endPositionInReferenceSequence; 23 | } 24 | 25 | public Integer getStartPositionInReferenceSequence() { 26 | return startPositionInReferenceSequence; 27 | } 28 | 29 | public void setStartPositionInReferenceSequence(Integer startPositionInReferenceSequence) { 30 | this.startPositionInReferenceSequence = startPositionInReferenceSequence; 31 | } 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/helper/StoichiometryObject.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service.helper; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | import org.springframework.lang.NonNull; 5 | 6 | @SuppressWarnings("unused") 7 | public class StoichiometryObject implements Comparable { 8 | 9 | private Integer stoichiometry; 10 | 11 | private DatabaseObject object; 12 | 13 | public StoichiometryObject(Integer stoichiometry, DatabaseObject object) { 14 | this.stoichiometry = stoichiometry; 15 | this.object = object; 16 | } 17 | 18 | public Integer getStoichiometry() { 19 | return stoichiometry; 20 | } 21 | 22 | public void setStoichiometry(Integer stoichiometry) { 23 | this.stoichiometry = stoichiometry; 24 | } 25 | 26 | public T getObject() { 27 | //noinspection unchecked 28 | return (T) object; 29 | } 30 | 31 | public void setObject(DatabaseObject object) { 32 | this.object = object; 33 | } 34 | 35 | @Override 36 | public int compareTo(@NonNull StoichiometryObject o) { 37 | return this.object.getDisplayName().compareToIgnoreCase(o.getObject().getDisplayName()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/schema/SchemaDataDownloadType.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.schema; 2 | 3 | public enum SchemaDataDownloadType { 4 | SBML ("SBML", "https://reactome.org/ContentService/exporter/sbml/__ID__.xml"), 5 | SBGN ("SBGN", "https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/sbgnExporter/__ID__"), 6 | BIOPAX_2 ("BIOPAX2", "https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/biopaxExporter/Level2/__ID__"), 7 | BIOPAX_3 ("BIOPAX3", "https://reactome.org/ReactomeRESTfulAPI/RESTfulWS/biopaxExporter/Level3/__ID__"), 8 | PDF ("PDF", "https://reactome.org/cgi-bin/pdfexporter?DB=gk_current&ID=__ID__"), 9 | WORD ("DOCX", "https://reactome.org/cgi-bin/rtfexporter?DB=gk_current&ID=__ID__"), 10 | PROTEGE ("OWL", "https://reactome.org/cgi-bin/protegeexporter?DB=gk_current&ID=__ID__"); 11 | 12 | private final String format; 13 | private final String url; 14 | 15 | SchemaDataDownloadType(String format, String url) { 16 | this.format = format; 17 | this.url = url; 18 | } 19 | 20 | public String getFormat() { 21 | return format; 22 | } 23 | 24 | public String getUrl(Long dbId){ 25 | return this.url.replace("__ID__", String.valueOf(dbId)); 26 | } 27 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/InterChainCrosslinkedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class InterChainCrosslinkedResidue extends CrosslinkedResidue { 12 | 13 | @Relationship(type = "equivalentTo") 14 | private List equivalentTo; 15 | 16 | @Relationship(type = "secondReferenceSequence") 17 | private Set secondReferenceSequence; 18 | 19 | public InterChainCrosslinkedResidue() {} 20 | 21 | public List getEquivalentTo() { 22 | return equivalentTo; 23 | } 24 | 25 | public void setEquivalentTo(List equivalentTo) { 26 | this.equivalentTo = equivalentTo; 27 | } 28 | 29 | public Set getSecondReferenceSequence() { 30 | return secondReferenceSequence; 31 | } 32 | 33 | public void setSecondReferenceSequence(Set secondReferenceSequence) { 34 | this.secondReferenceSequence = secondReferenceSequence; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/SchemaClassCount.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | 4 | 5 | import org.neo4j.driver.Record; 6 | import org.neo4j.driver.Value; 7 | 8 | import java.util.Collection; 9 | 10 | /** 11 | * Created by: 12 | * 13 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 14 | * @since 21.01.16. 15 | * 16 | * Object for retrieving all different labels and their counts from the graph 17 | */ 18 | @SuppressWarnings("unused") 19 | public class SchemaClassCount { 20 | 21 | private int count; 22 | private Collection labels; 23 | 24 | public int getCount() { 25 | return count; 26 | } 27 | 28 | public void setCount(int count) { 29 | this.count = count; 30 | } 31 | 32 | public Collection getLabels() { 33 | return labels; 34 | } 35 | 36 | public void setLabels(Collection labels) { 37 | this.labels = labels; 38 | } 39 | 40 | public static SchemaClassCount build(Record record) { 41 | SchemaClassCount schemaClassCount = new SchemaClassCount(); 42 | schemaClassCount.setCount(record.get("count").asInt()); 43 | schemaClassCount.setLabels(record.get("labels").asList(Value::asString)); 44 | return schemaClassCount; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/DeletedInstanceServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | import org.reactome.server.graph.domain.model.DeletedInstance; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | public class DeletedInstanceServiceTest extends BaseTest { 12 | 13 | @Autowired 14 | private DeletedInstanceService deletedInstanceService; 15 | 16 | 17 | @Test 18 | public void getDeletedInstanceByDbId() { 19 | Optional deletedInstance = this.deletedInstanceService.getDeletedInstanceByDbId(9745160L); 20 | Assertions.assertTrue(deletedInstance.isPresent()); 21 | 22 | int deletedInstanceDbId = deletedInstance.get().getDeletedInstanceDbId(); 23 | Assertions.assertNotNull(deletedInstanceDbId); 24 | 25 | String deletedStId = deletedInstance.get().getDeletedStId(); 26 | Assertions.assertNotNull(deletedStId); 27 | } 28 | 29 | @Test 30 | public void getByDeletedDbId() { 31 | List deletedInstances = this.deletedInstanceService.getByDeletedDbId(5655667L); 32 | Assertions.assertFalse(deletedInstances.isEmpty()); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/ReferenceEntityServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.reactome.server.graph.domain.model.ReferenceEntity; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.test.context.event.annotation.BeforeTestClass; 7 | 8 | import java.util.Collection; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | 12 | public class ReferenceEntityServiceTest extends BaseTest { 13 | 14 | @Autowired ReferenceEntityService referenceEntityService; 15 | 16 | @BeforeTestClass 17 | public void setUpClass() { 18 | logger.info(" --- !!! Running " + ReferenceEntityServiceTest.class.getName() + " !!! --- \n"); 19 | } 20 | 21 | @Test 22 | public void testGetReferenceEntitiesFor() { 23 | 24 | logger.info("Started testing databaseObjectService.testGetParticipantsByStId"); 25 | long start, time; 26 | start = System.currentTimeMillis(); 27 | Collection refs = referenceEntityService.getReferenceEntitiesFor("15377"); 28 | time = System.currentTimeMillis() - start; 29 | logger.info("GraphDb execution time: " + time + "ms"); 30 | 31 | assertEquals(3, refs.size()); 32 | logger.info("Finished"); 33 | } 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/InstanceEdit.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class InstanceEdit extends DatabaseObject { 12 | 13 | @ReactomeProperty 14 | private String dateTime; 15 | @ReactomeProperty 16 | private String note; 17 | 18 | @Relationship(type = "author", direction = Relationship.Direction.INCOMING) 19 | private List author; 20 | 21 | public InstanceEdit() {} 22 | 23 | public InstanceEdit(Long dbId) { 24 | super(dbId); 25 | } 26 | 27 | public String getDateTime() { 28 | return this.dateTime; 29 | } 30 | 31 | public void setDateTime(String dateTime) { 32 | this.dateTime = dateTime; 33 | } 34 | 35 | public String getNote() { 36 | return this.note; 37 | } 38 | 39 | public void setNote(String note) { 40 | this.note = note; 41 | } 42 | 43 | public List getAuthor() { 44 | return author; 45 | } 46 | 47 | public void setAuthor(List author) { 48 | this.author = author; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/helper/EnhancedQueryOptions.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service.helper; 2 | 3 | 4 | public class EnhancedQueryOptions { 5 | public boolean summariseReferenceEntity = false; 6 | public boolean includeDisease = false; 7 | public boolean outgoingOnly = false; 8 | 9 | public EnhancedQueryOptions() { 10 | } 11 | 12 | public EnhancedQueryOptions(boolean summariseReferenceEntity, boolean includeDisease, boolean outgoingOnly) { 13 | this.summariseReferenceEntity = summariseReferenceEntity; 14 | this.includeDisease = includeDisease; 15 | this.outgoingOnly = outgoingOnly; 16 | } 17 | 18 | public boolean summarisesReferenceEntity() { 19 | return summariseReferenceEntity; 20 | } 21 | 22 | public void setSummariseReferenceEntity(boolean summariseReferenceEntity) { 23 | this.summariseReferenceEntity = summariseReferenceEntity; 24 | } 25 | 26 | public boolean includesDisease() { 27 | return includeDisease; 28 | } 29 | 30 | public void setIncludeDisease(boolean includeDisease) { 31 | this.includeDisease = includeDisease; 32 | } 33 | 34 | public boolean isOutgoingOnly() { 35 | return outgoingOnly; 36 | } 37 | 38 | public void setOutgoingOnly(boolean outgoingOnly) { 39 | this.outgoingOnly = outgoingOnly; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/UpdateTrackerRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.UpdateTracker; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | import java.util.Optional; 11 | 12 | @Repository 13 | public interface UpdateTrackerRepository extends Neo4jRepository { 14 | 15 | //language=cypher 16 | @Query(" MATCH (d:UpdateTracker {dbId:$dbId}) " + 17 | "OPTIONAL MATCH (d)-[r]-(m) " + 18 | "RETURN d, collect(r), collect(m)") 19 | Optional findUpdateTrackerByDbId(@Param("dbId") Long dbId); 20 | 21 | 22 | //language=cypher 23 | @Query(" MATCH(u:UpdateTracker)-[:updatedInstance]->(t:Trackable) " + 24 | "WHERE t.dbId = $dbId " + 25 | "RETURN u") 26 | List findByUpdatedInstanceDbId(@Param("dbId") Long dbId); 27 | 28 | //language=cypher 29 | @Query(" MATCH(d:UpdateTracker)-[:updatedInstance]->(t:Trackable) " + 30 | "WHERE t.stId = $stId " + 31 | "RETURN d ") 32 | List findByUpdatedInstanceStId(@Param("stId") String stId); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/NegativePrecedingEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @Node 10 | public class NegativePrecedingEvent extends DatabaseObject { 11 | 12 | @ReactomeProperty 13 | private String comment; 14 | 15 | @Relationship(type = "negativePrecedingEvent", direction = Relationship.Direction.INCOMING) 16 | private List precedingEvent; 17 | 18 | @Relationship(type = "reason") 19 | private NegativePrecedingEventReason reason; 20 | 21 | public NegativePrecedingEvent() { 22 | } 23 | 24 | public String getComment() { 25 | return comment; 26 | } 27 | 28 | public void setComment(String comment) { 29 | this.comment = comment; 30 | } 31 | 32 | public List getPrecedingEvent() { 33 | return precedingEvent; 34 | } 35 | 36 | public void setPrecedingEvent(List precedingEvent) { 37 | this.precedingEvent = precedingEvent; 38 | } 39 | 40 | public NegativePrecedingEventReason getReason() { 41 | return reason; 42 | } 43 | 44 | public void setReason(NegativePrecedingEventReason reason) { 45 | this.reason = reason; 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/SimpleReferenceObject.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import org.neo4j.driver.Record; 4 | 5 | 6 | @SuppressWarnings("unused") 7 | public class SimpleReferenceObject { 8 | 9 | private Long dbId; 10 | private String identifier; 11 | private String databaseName; 12 | 13 | public SimpleReferenceObject() { 14 | } 15 | 16 | public Long getDbId() { 17 | return dbId; 18 | } 19 | 20 | public void setDbId(Long dbId) { 21 | this.dbId = dbId; 22 | } 23 | 24 | public String getIdentifier() { 25 | return identifier; 26 | } 27 | 28 | public void setIdentifier(String identifier) { 29 | this.identifier = identifier; 30 | } 31 | 32 | public String getDatabaseName() { 33 | return databaseName; 34 | } 35 | 36 | public void setDatabaseName(String databaseName) { 37 | this.databaseName = databaseName; 38 | } 39 | 40 | public static SimpleReferenceObject build(Record record) { 41 | SimpleReferenceObject simpleReferenceObject = new SimpleReferenceObject(); 42 | simpleReferenceObject.setDbId(record.get("dbId").asLong()); 43 | simpleReferenceObject.setIdentifier(record.get("identifier").asString()); 44 | simpleReferenceObject.setDatabaseName(record.get("databaseName").asString()); 45 | return simpleReferenceObject; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/DiagramResult.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import java.util.List; 4 | 5 | public class DiagramResult { 6 | 7 | private String diagramStId; 8 | private List events; 9 | private Integer width; 10 | private Integer height; 11 | 12 | public DiagramResult() { } 13 | 14 | public DiagramResult(String diagramStId, List events, Integer width, Integer height) { 15 | this.diagramStId = diagramStId; 16 | this.events = events; 17 | this.width = width; 18 | this.height = height; 19 | } 20 | 21 | public String getDiagramStId() { 22 | return diagramStId; 23 | } 24 | 25 | public void setDiagramStId(String diagramStId) { 26 | this.diagramStId = diagramStId; 27 | } 28 | 29 | public List getEvents() { 30 | return events; 31 | } 32 | 33 | public void setEvents(List events) { 34 | this.events = events; 35 | } 36 | 37 | public Integer getWidth() { 38 | return width; 39 | } 40 | 41 | public void setWidth(Integer width) { 42 | this.width = width; 43 | } 44 | 45 | public Integer getHeight() { 46 | return height; 47 | } 48 | 49 | public void setHeight(Integer height) { 50 | this.height = height; 51 | } 52 | 53 | public Integer getSize(){ 54 | return width * height; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/config/GraphCoreNeo4jConfig.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.config; 2 | 3 | import org.aspectj.lang.Aspects; 4 | import org.reactome.server.graph.aop.LazyFetchAspect; 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 6 | import org.springframework.boot.autoconfigure.domain.EntityScan; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.ComponentScan; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.context.annotation.aspectj.EnableSpringConfigured; 11 | import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; 12 | import org.springframework.transaction.annotation.EnableTransactionManagement; 13 | 14 | @Configuration 15 | @ComponentScan(basePackages = "org.reactome.server.graph") 16 | @EntityScan(basePackages = "org.reactome.server.graph.domain.model") 17 | @EnableNeo4jRepositories(basePackages = "org.reactome.server.graph.repository") 18 | @EnableTransactionManagement 19 | @EnableSpringConfigured 20 | @EnableAutoConfiguration 21 | public class GraphCoreNeo4jConfig { 22 | 23 | /** 24 | * This is needed to get hold of the instance of the aspect which is created outside of the spring container, 25 | * and make it available for autowiring. 26 | */ 27 | @Bean 28 | public LazyFetchAspect lazyFetchAspect() { 29 | return Aspects.aspectOf(LazyFetchAspect.class); 30 | } 31 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/FailedReaction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | 7 | /** 8 | * Defines an event where genetic mutations in the nucleotide sequence produces a protein with a very little or no activity. The consequence of this is that substrates are not converted to products and can therefore build up to cause pathological conditions. It could also mean entities are not moved between compartments again causing imbalances in entity concentrations which can lead to pathological conditions. 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class FailedReaction extends ReactionLikeEvent { 13 | 14 | public FailedReaction() {} 15 | 16 | @ReactomeSchemaIgnore 17 | @Override 18 | @JsonIgnore 19 | public String getExplanation() { 20 | return "Defines an event where genetic mutations in the nucleotide sequence produces a protein with a very little or no activity. " + 21 | "The consequence of this is that substrates are not converted to products and can therefore build up to cause pathological conditions. " + 22 | "It could also mean entities are not moved between compartments again causing imbalances in entity concentrations which can lead to pathological conditions."; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/InteractorCountRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.result.InteractorsCount; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.data.neo4j.core.Neo4jClient; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | import java.util.Collections; 11 | 12 | @Repository 13 | public class InteractorCountRepository { 14 | 15 | private final Neo4jClient neo4jClient; 16 | 17 | @Value("${spring.data.neo4j.database:graph.db}") 18 | private String databaseName; 19 | 20 | @Autowired 21 | public InteractorCountRepository(Neo4jClient neo4jClient) { 22 | this.neo4jClient = neo4jClient; 23 | } 24 | 25 | public Collection countByAccessions(Collection accs) { 26 | String query = " " + 27 | "MATCH (t:ReferenceEntity)<-[:interactor]-(in:Interaction) " + 28 | "WHERE t.variantIdentifier IN $accs OR (t.variantIdentifier IS NULL AND t.identifier IN $accs) " + 29 | "RETURN DISTINCT t.identifier AS s, COUNT(DISTINCT in) as t"; 30 | return neo4jClient.query(query).in(databaseName).bindAll(Collections.singletonMap("accs", accs)).fetchAs(InteractorsCount.class).mappedBy( (t, s) -> InteractorsCount.build(s)).all(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GenomeEncodedEntity.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | import org.springframework.data.neo4j.core.schema.Relationship; 7 | 8 | /** 9 | * A peptide or polynucleotide whose sequence is unknown and thus cannot be linked to external sequence databases or used for orthology inference. 10 | */ 11 | @SuppressWarnings("unused") 12 | @Node 13 | public class GenomeEncodedEntity extends PhysicalEntity { 14 | 15 | 16 | @Relationship(type = "species") 17 | private Taxon species; 18 | 19 | public GenomeEncodedEntity() {} 20 | 21 | public GenomeEncodedEntity(Long dbId) { 22 | super(dbId); 23 | } 24 | 25 | public Taxon getSpecies() { 26 | return species; 27 | } 28 | 29 | public void setSpecies(Taxon species) { 30 | this.species = species; 31 | } 32 | 33 | @ReactomeSchemaIgnore 34 | @Override 35 | @JsonIgnore 36 | public String getExplanation() { 37 | return "A peptide or polynucleotide whose sequence is unknown and thus cannot be linked to external sequence databases or used for orthology inference"; 38 | } 39 | 40 | @ReactomeSchemaIgnore 41 | @Override 42 | public String getClassName() { 43 | return "Genes and Transcripts"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/TranslationalModification.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | import org.springframework.data.neo4j.core.schema.Relationship; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public abstract class TranslationalModification extends AbstractModifiedResidue { 11 | 12 | @ReactomeProperty 13 | private Integer coordinate; 14 | 15 | @JsonIgnore 16 | @ReactomeProperty(addedField = true) //filled by the diagram-converter 17 | private String label; 18 | 19 | @Relationship(type = "psiMod") 20 | private PsiMod psiMod; 21 | 22 | public TranslationalModification() {} 23 | 24 | public TranslationalModification(Long dbId) { 25 | super(dbId); 26 | } 27 | 28 | public Integer getCoordinate() { 29 | return coordinate; 30 | } 31 | 32 | public void setCoordinate(Integer coordinate) { 33 | this.coordinate = coordinate; 34 | } 35 | 36 | public String getLabel() { 37 | return label; 38 | } 39 | 40 | public void setLabel(String label) { 41 | this.label = label; 42 | } 43 | 44 | public PsiMod getPsiMod() { 45 | return psiMod; 46 | } 47 | 48 | public void setPsiMod(PsiMod psiMod) { 49 | this.psiMod = psiMod; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/EntityFunctionalStatus.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class EntityFunctionalStatus extends DatabaseObject { 11 | 12 | @Relationship(type = "functionalStatus") 13 | private List functionalStatus; 14 | 15 | //Formerly "physicalEntity" 16 | @Relationship(type = "diseaseEntity") 17 | private PhysicalEntity diseaseEntity; 18 | 19 | @Relationship(type = "normalEntity") 20 | private PhysicalEntity normalEntity; 21 | 22 | public EntityFunctionalStatus() {} 23 | 24 | public List getFunctionalStatus() { 25 | return functionalStatus; 26 | } 27 | 28 | public void setFunctionalStatus(List functionalStatus) { 29 | this.functionalStatus = functionalStatus; 30 | } 31 | 32 | public PhysicalEntity getDiseaseEntity() { 33 | return diseaseEntity; 34 | } 35 | 36 | public void setDiseaseEntity(PhysicalEntity diseaseEntity) { 37 | this.diseaseEntity = diseaseEntity; 38 | } 39 | 40 | public PhysicalEntity getNormalEntity() { 41 | return normalEntity; 42 | } 43 | 44 | public void setNormalEntity(PhysicalEntity normalEntity) { 45 | this.normalEntity = normalEntity; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Publication.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonView; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.reactome.server.graph.domain.annotations.StoichiometryView; 6 | import org.reactome.server.graph.domain.relationship.Has; 7 | import org.reactome.server.graph.domain.relationship.PublicationAuthor; 8 | import org.springframework.data.neo4j.core.schema.Node; 9 | import org.springframework.data.neo4j.core.schema.Relationship; 10 | 11 | import java.util.List; 12 | import java.util.SortedSet; 13 | 14 | @SuppressWarnings("unused") 15 | @Node 16 | public abstract class Publication extends DatabaseObject { 17 | 18 | @ReactomeProperty 19 | private String title; 20 | 21 | @Relationship(type = "author", direction = Relationship.Direction.INCOMING) 22 | private SortedSet author; 23 | 24 | public Publication() {} 25 | 26 | public Publication(Long dbId) { 27 | super(dbId); 28 | } 29 | 30 | public String getTitle() { 31 | return title; 32 | } 33 | 34 | public void setTitle(String title) { 35 | this.title = title; 36 | } 37 | 38 | public List getAuthor() { 39 | return Has.Util.expandStoichiometry(author); 40 | } 41 | 42 | public void setAuthor(List author) { 43 | this.author = Has.Util.aggregateStoichiometry(author, PublicationAuthor::new); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/BlackBoxEvent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | /** 8 | * Shortcut reactions that make the connection between input and output, but don't provide complete mechanistic detail. Used for reactions that do not balance, or complicated processes for which we either don't know all the details, or we choose not to represent every step. (e.g. degradation of a protein) 9 | */ 10 | @SuppressWarnings("unused") 11 | @Node 12 | public class BlackBoxEvent extends ReactionLikeEvent { 13 | 14 | @ReactomeSchemaIgnore 15 | @Override 16 | public String getExplanation() { 17 | return "Shortcut reactions that make the connection between input and output, but don't provide complete mechanistic detail. " + 18 | "Used for reactions that do not balance, or complicated processes for which we either don't know all the details, or we choose not to represent every step. (e.g. degradation of a protein)"; 19 | 20 | } 21 | 22 | @Relationship(type = "templateEvent") 23 | private Event templateEvent; 24 | 25 | public BlackBoxEvent() {} 26 | 27 | public Event getTemplateEvent() { 28 | return templateEvent; 29 | } 30 | 31 | public void setTemplateEvent(Event templateEvent) { 32 | this.templateEvent = templateEvent; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/OrthologyServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.reactome.server.graph.domain.model.DatabaseObject; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.test.context.event.annotation.BeforeTestClass; 7 | 8 | import java.util.Collection; 9 | 10 | import static org.junit.jupiter.api.Assertions.assertNotNull; 11 | import static org.springframework.test.util.AssertionErrors.assertTrue; 12 | 13 | public class OrthologyServiceTest extends BaseTest { 14 | 15 | @Autowired 16 | private OrthologyService orthologyService; 17 | 18 | @BeforeTestClass 19 | public void setUpClass() { 20 | logger.info(" --- !!! Running " + OrthologyServiceTest.class.getName() + " !!! --- \n"); 21 | } 22 | 23 | @Test 24 | public void getOrthologyTest() { 25 | logger.info("Started testing orthologyService.getOrthology"); 26 | long start = System.currentTimeMillis(); 27 | Collection orthology = orthologyService.getOrthology("R-HSA-6799198", 49633L); 28 | long time = System.currentTimeMillis() - start; 29 | logger.info("GraphDb execution time: " + time + "ms"); 30 | 31 | assertNotNull(orthology.iterator().next().getStId(), "The orthology cannot be null"); 32 | assertTrue("The orthologous of 'R-HSA-6799198' for 'Sus scrofa' is 'R-SSC-6799198'", orthology.iterator().next().getStId().equals("R-SSC-6799198")); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/custom/CustomQueryPhysicalEntity.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.custom; 2 | 3 | import org.neo4j.driver.Record; 4 | import org.reactome.server.graph.domain.result.CustomQuery; 5 | 6 | /** 7 | * POJO for testing the Custom Cypher Queries 8 | * 9 | * @author Guilherme S Viteri 10 | */ 11 | @SuppressWarnings("unused") 12 | public class CustomQueryPhysicalEntity implements CustomQuery { 13 | 14 | private String stId; 15 | private String displayName; 16 | private CustomReference customReference; 17 | 18 | public String getStId() { 19 | return stId; 20 | } 21 | 22 | public void setStId(String stId) { 23 | this.stId = stId; 24 | } 25 | 26 | public String getDisplayName() { 27 | return displayName; 28 | } 29 | 30 | public void setDisplayName(String displayName) { 31 | this.displayName = displayName; 32 | } 33 | 34 | public CustomReference getCustomReference() { 35 | return customReference; 36 | } 37 | 38 | public void setCustomReference(CustomReference customReference) { 39 | this.customReference = customReference; 40 | } 41 | 42 | @Override 43 | public CustomQuery build(Record r) { 44 | this.setStId(r.get("stId").asString()); 45 | this.setDisplayName(r.get("displayName").asString()); 46 | this.setCustomReference(new CustomReference(r.get("customReference").get("database").asString(), r.get("customReference").get("identifier").asString())); 47 | return this; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/schema/SchemaPerson.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.schema; 2 | 3 | import com.fasterxml.jackson.annotation.JsonGetter; 4 | import org.reactome.server.graph.domain.model.Affiliation; 5 | import org.reactome.server.graph.domain.model.Person; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | @SuppressWarnings("unused") 11 | public class SchemaPerson extends SchemaCreator { 12 | 13 | private final String givenName; 14 | private final String familyName; 15 | private final List affiliation = new ArrayList<>(); 16 | private final String url; //For the orcidId 17 | 18 | SchemaPerson(Person person) { 19 | this.givenName = person.getFirstname(); 20 | this.familyName = person.getSurname(); 21 | if(person.getAffiliation()!=null) { 22 | for (Affiliation a : person.getAffiliation()) { 23 | this.affiliation.add(new SchemaOrganization(a)); 24 | } 25 | } 26 | url = "http://europepmc.org/authors/" + person.getOrcidId(); 27 | } 28 | 29 | public String getGivenName() { 30 | return givenName; 31 | } 32 | 33 | public String getFamilyName() { 34 | return familyName; 35 | } 36 | 37 | public List getAffiliation() { 38 | return affiliation; 39 | } 40 | 41 | public String getUrl() { 42 | return url; 43 | } 44 | 45 | @JsonGetter(value = "@type") 46 | public String getType(){ 47 | return "Person"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /release_github.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit on error 4 | set -e 5 | 6 | # Check if required commands are installed 7 | if ! command -v mvn &> /dev/null; then 8 | echo "Error: Maven (mvn) is not installed." 9 | exit 1 10 | fi 11 | 12 | if ! command -v gh &> /dev/null; then 13 | echo "Error: GitHub CLI (gh) is not installed." 14 | exit 1 15 | fi 16 | 17 | # Get the version from Maven 18 | VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 19 | 20 | # Ensure version is not empty 21 | if [[ -z "$VERSION" ]]; then 22 | echo "Error: Failed to retrieve project version." 23 | exit 1 24 | fi 25 | 26 | # Check if the release already exists on GitHub 27 | if gh release view "$VERSION" &> /dev/null; then 28 | echo "Release $VERSION already exists. Deleting..." 29 | gh release delete "$VERSION" --yes 30 | fi 31 | 32 | # Check if the tag exists locally 33 | if git rev-parse "$VERSION" >/dev/null 2>&1; then 34 | echo "Tag $VERSION exists locally." 35 | 36 | # Check if the tag exists on GitHub 37 | if git ls-remote --tags origin | grep -q "refs/tags/$VERSION"; then 38 | echo "Tag $VERSION exists on GitHub. Deleting..." 39 | git push --delete origin "$VERSION" 40 | fi 41 | 42 | echo "Recreating tag $VERSION..." 43 | git tag -d "$VERSION" 44 | fi 45 | 46 | # Create and push the tag again 47 | git tag "$VERSION" 48 | git push origin "$VERSION" 49 | 50 | # Create a new release 51 | gh release create "$VERSION" --title "Version $VERSION" --notes "New Version Release" 52 | 53 | echo "GitHub release $VERSION created successfully!" 54 | 55 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/DeletedRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.Deleted; 4 | import org.springframework.data.neo4j.core.Neo4jClient; 5 | import org.springframework.data.neo4j.core.Neo4jTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | import java.util.Map; 10 | import java.util.Optional; 11 | 12 | @Repository 13 | public class DeletedRepository { 14 | 15 | 16 | private final Neo4jTemplate neo4jTemplate; 17 | 18 | public DeletedRepository(Neo4jTemplate neo4jTemplate, Neo4jClient neo4jClient) { 19 | this.neo4jTemplate = neo4jTemplate; 20 | 21 | } 22 | 23 | public Optional getDeletedByDbId(Long dbId) { 24 | String query = "MATCH (d:Deleted{dbId:$dbId}) OPTIONAL MATCH (d)-[r]-(m) RETURN d, COLLECT(r), COLLECT(m)"; 25 | return neo4jTemplate.findOne(query, Map.of("dbId", dbId), Deleted.class); 26 | } 27 | 28 | 29 | public List getByDeletedInstanceDbId(Long dbId) { 30 | String query = "MATCH (p:Deleted)-[r:deletedInstance*]->(d:DeletedInstance) WHERE d.dbId = $dbId RETURN COLLECT(p)"; 31 | return neo4jTemplate.findAll(query, Map.of("dbId", dbId), Deleted.class); 32 | } 33 | 34 | 35 | public List getByReplacementStId(String stId) { 36 | String query = "MATCH (p:Deleted)-[r:replacementInstances*]->(d:Deletable) WHERE d.stId = $stId RETURN COLLECT(p)"; 37 | return neo4jTemplate.findAll(query, Map.of("stId", stId), Deleted.class); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 11 | 12 | 13 | 14 | 15 | 16 | @logging.dir@/graph/graph-tests-%d{yyyy-MM-dd}.log 17 | true 18 | -1 19 | 20 | 21 | %d %-5level [%thread] %logger{0}: %msg%n 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/DiagramOccurrences.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import java.util.List; 4 | 5 | public class DiagramOccurrences { 6 | 7 | private String diagramStId; 8 | private Boolean inDiagram; 9 | private Boolean inDiagramFromInteractor; 10 | private List occurrences; 11 | private List occurrencesInteractor; 12 | private List interactsWith; 13 | 14 | public DiagramOccurrences() { } 15 | 16 | public DiagramOccurrences(String diagramStId, Boolean inDiagram, Boolean inDiagramFromInteractor, List occurrences, List occurrencesInteractor, List interactsWith) { 17 | this.diagramStId = diagramStId; 18 | this.inDiagram = inDiagram; 19 | this.inDiagramFromInteractor = inDiagramFromInteractor; 20 | this.occurrences = occurrences; 21 | this.occurrencesInteractor = occurrencesInteractor; 22 | this.interactsWith = interactsWith; 23 | } 24 | 25 | public String getDiagramStId() { 26 | return diagramStId; 27 | } 28 | 29 | public Boolean isInDiagram() { 30 | return inDiagram; 31 | } 32 | 33 | public Boolean isInDiagramFromInteractor() { 34 | return inDiagramFromInteractor; 35 | } 36 | 37 | public List getOccurrences() { 38 | return occurrences; 39 | } 40 | 41 | public List getOccurrencesInteractor() { 42 | return occurrencesInteractor; 43 | } 44 | 45 | public List getInteractsWith() { 46 | return interactsWith; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceGeneProduct.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class ReferenceGeneProduct extends ReferenceSequence { 12 | 13 | @ReactomeProperty 14 | private List chain; 15 | 16 | @Relationship(type = "referenceGene") 17 | private List referenceGene; 18 | 19 | @Relationship(type = "referenceTranscript") 20 | private List referenceTranscript; 21 | 22 | public ReferenceGeneProduct() { 23 | super(); 24 | this.setMoleculeType("Protein"); 25 | } 26 | 27 | public List getChain() { 28 | return chain; 29 | } 30 | 31 | public void setChain(List chain) { 32 | this.chain = chain; 33 | } 34 | 35 | public List getReferenceGene() { 36 | return referenceGene; 37 | } 38 | 39 | public void setReferenceGene(List referenceGene) { 40 | this.referenceGene = referenceGene; 41 | } 42 | 43 | public List getReferenceTranscript() { 44 | return referenceTranscript; 45 | } 46 | 47 | public void setReferenceTranscript(List referenceTranscript) { 48 | this.referenceTranscript = referenceTranscript; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/QueryResultWrapper.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | 5 | public class QueryResultWrapper { 6 | private DatabaseObject databaseObject; 7 | private int stoichiometry; 8 | 9 | public QueryResultWrapper(DatabaseObject databaseObject) { 10 | this(databaseObject, 1); 11 | } 12 | 13 | public QueryResultWrapper(DatabaseObject databaseObject, int stoichiometry) { 14 | this.databaseObject = databaseObject; 15 | this.stoichiometry = stoichiometry; 16 | } 17 | 18 | public DatabaseObject getDatabaseObject() { 19 | return databaseObject; 20 | } 21 | 22 | public void setDatabaseObject(DatabaseObject databaseObject) { 23 | this.databaseObject = databaseObject; 24 | } 25 | 26 | public int getStoichiometry() { 27 | return stoichiometry; 28 | } 29 | 30 | public void setStoichiometry(int stoichiometry) { 31 | this.stoichiometry = stoichiometry; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (!(o instanceof QueryResultWrapper)) return false; 38 | 39 | QueryResultWrapper that = (QueryResultWrapper) o; 40 | 41 | if (stoichiometry != that.stoichiometry) return false; 42 | return databaseObject.equals(that.databaseObject); 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | int result = databaseObject.hashCode(); 48 | result = 31 * result + stoichiometry; 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/OrthologyRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | 11 | @Repository 12 | public interface OrthologyRepository extends Neo4jRepository { 13 | 14 | //The relationship do not have direction because that's what is needed in this case 15 | @Query(" MATCH (:DatabaseObject{dbId:$dbId})<-[:inferredTo]-()-[:inferredTo]->(o:DatabaseObject)-[:species]->(:Species{dbId:$speciesId}) RETURN DISTINCT o " + 16 | "UNION " + 17 | "MATCH (:DatabaseObject{dbId:$dbId})-[:inferredTo]-(o:DatabaseObject)-[:species]->(:Species{dbId:$speciesId}) RETURN DISTINCT o") 18 | Collection getOrthology(@Param("dbId") Long dbId, @Param("speciesId") Long speciesId); 19 | 20 | //The relationship do not have direction because that's what is needed in this case 21 | @Query(" MATCH (:DatabaseObject{stId:$stId})<-[:inferredTo]-()-[:inferredTo]->(o:DatabaseObject)-[:species]->(:Species{dbId:$speciesId}) RETURN DISTINCT o " + 22 | "UNION " + 23 | "MATCH (:DatabaseObject{stId:$stId})-[:inferredTo]-(o:DatabaseObject)-[:species]->(:Species{dbId:$speciesId}) RETURN DISTINCT o") 24 | Collection getOrthology(@Param("stId") String stId, @Param("speciesId") Long speciesId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Book.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | @SuppressWarnings("unused") 8 | @Node 9 | public class Book extends Publication { 10 | 11 | @ReactomeProperty 12 | private String ISBN; 13 | @ReactomeProperty 14 | private String chapterTitle; 15 | @ReactomeProperty 16 | private String pages; 17 | @ReactomeProperty 18 | private Integer year; 19 | 20 | @Relationship(type = "publisher") 21 | private Affiliation publisher; 22 | 23 | public Book() {} 24 | 25 | public String getISBN() { 26 | return ISBN; 27 | } 28 | 29 | public void setISBN(String ISBN) { 30 | this.ISBN = ISBN; 31 | } 32 | 33 | public String getChapterTitle() { 34 | return chapterTitle; 35 | } 36 | 37 | public void setChapterTitle(String chapterTitle) { 38 | this.chapterTitle = chapterTitle; 39 | } 40 | 41 | public String getPages() { 42 | return pages; 43 | } 44 | 45 | public void setPages(String pages) { 46 | this.pages = pages; 47 | } 48 | 49 | public Integer getYear() { 50 | return year; 51 | } 52 | 53 | public void setYear(Integer year) { 54 | this.year = year; 55 | } 56 | 57 | public Affiliation getPublisher() { 58 | return publisher; 59 | } 60 | 61 | public void setPublisher(Affiliation publisher) { 62 | this.publisher = publisher; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Taxon.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class Taxon extends DatabaseObject { 12 | 13 | @ReactomeProperty 14 | private List name; 15 | @ReactomeProperty(addedField = true) 16 | private String taxId; 17 | 18 | @Deprecated 19 | @Relationship(type = "crossReference") 20 | private List crossReference; 21 | 22 | @Relationship(type = "superTaxon") 23 | private Taxon superTaxon; 24 | 25 | public Taxon() {} 26 | 27 | public List getName() { 28 | return name; 29 | } 30 | 31 | public void setName(List name) { 32 | this.name = name; 33 | } 34 | 35 | public String getTaxId() { 36 | return taxId; 37 | } 38 | 39 | public void setTaxId(String taxId) { 40 | this.taxId = taxId; 41 | } 42 | 43 | @Deprecated 44 | public List getCrossReference() { 45 | return crossReference; 46 | } 47 | 48 | @Deprecated 49 | public void setCrossReference(List crossReference) { 50 | this.crossReference = crossReference; 51 | } 52 | 53 | public Taxon getSuperTaxon() { 54 | return superTaxon; 55 | } 56 | 57 | public void setSuperTaxon(Taxon superTaxon) { 58 | this.superTaxon = superTaxon; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.Person; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | 11 | @Repository 12 | public interface PersonRepository extends Neo4jRepository{ 13 | 14 | @Query(" MATCH (n:Person) " + 15 | "WHERE n.surname in $name AND n.firstname in $name " + 16 | "OPTIONAL MATCH (n)-[r]->(m) WHERE NOT (m:InstanceEdit) " + 17 | "RETURN n, COLLECT(r), COLLECT(m)") 18 | Collection findPersonByName(@Param("name") String[] name); 19 | 20 | @Query(" MATCH (n:Person) " + 21 | "WHERE n.surname in $name OR n.firstname in $name " + 22 | "OPTIONAL MATCH (n)-[r]->(m) WHERE NOT (m:InstanceEdit) " + 23 | "RETURN n, COLLECT(r), COLLECT(m)") 24 | Collection queryPersonByName(@Param("name") String[] name); 25 | 26 | @Query(" MATCH (n:Person{orcidId:$orcidId}) " + 27 | "OPTIONAL MATCH (n)-[r]->(m) WHERE NOT (m:InstanceEdit) " + 28 | "RETURN n, COLLECT(r), COLLECT(m)") 29 | Person findPersonByOrcidId(@Param("orcidId") String orcidId); 30 | 31 | @Query(" MATCH (n:Person{dbId:$dbId}) " + 32 | "OPTIONAL MATCH (n)-[r]->(m) WHERE NOT (m:InstanceEdit) " + 33 | "RETURN n, COLLECT(r), COLLECT(m)") 34 | Person findPersonByDbId(@Param("dbId") Long dbId); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/DeletedServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | import org.reactome.server.graph.domain.model.*; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | import java.util.List; 9 | import java.util.Optional; 10 | 11 | public class DeletedServiceTest extends BaseTest { 12 | 13 | @Autowired 14 | DeletedService service; 15 | 16 | @Test 17 | public void testFindDeletedByDbId() { 18 | 19 | Optional deleted = service.getDeletedByDbId(8869329L); 20 | Assertions.assertTrue(deleted.isPresent()); 21 | 22 | List deletedInstances = deleted.get().getDeletedInstance(); 23 | Assertions.assertTrue(!deletedInstances.isEmpty()); 24 | 25 | List deletables = deleted.get().getReplacementInstances(); 26 | Assertions.assertTrue(!deletables.isEmpty()); 27 | 28 | DeletedControlledVocabulary dcv = deleted.get().getReason(); 29 | Assertions.assertNotNull(dcv); 30 | 31 | Assertions.assertTrue(deletables.stream().anyMatch(deletable -> deletable instanceof NegativeRegulation)); 32 | } 33 | 34 | @Test 35 | public void testGetByDeletedInstanceDbId() { 36 | List deleteds = this.service.getByDeletedInstanceDbId(9745855L); 37 | Assertions.assertTrue(!deleteds.isEmpty()); 38 | } 39 | 40 | @Test 41 | public void testGetDeletedByReplacementInstancesStId() { 42 | List deleteds = this.service.getByReplacementStId("R-RNO-164402"); 43 | Assertions.assertTrue(!deleteds.isEmpty()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/CrosslinkedResidue.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeAllowedClasses; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | import org.springframework.data.neo4j.core.schema.Relationship; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public abstract class CrosslinkedResidue extends TranslationalModification { 11 | 12 | @ReactomeProperty 13 | private Integer secondCoordinate; 14 | 15 | @Relationship(type = "modification") 16 | @ReactomeAllowedClasses(allowed = {EntitySet.class, Polymer.class, ReferenceGroup.class}) 17 | private DatabaseObject modification; 18 | 19 | public CrosslinkedResidue() {} 20 | 21 | public Integer getSecondCoordinate() { 22 | return secondCoordinate; 23 | } 24 | 25 | public void setSecondCoordinate(Integer secondCoordinate) { 26 | this.secondCoordinate = secondCoordinate; 27 | } 28 | 29 | @ReactomeAllowedClasses(allowed = {EntitySet.class, Polymer.class, ReferenceGroup.class}) 30 | public DatabaseObject getModification() { 31 | return modification; 32 | } 33 | 34 | public void setModification(DatabaseObject modification) { 35 | if(modification == null) return; 36 | 37 | 38 | if (modification instanceof Polymer || modification instanceof ReferenceGroup || modification instanceof EntitySet) { 39 | this.modification = modification; 40 | } else { 41 | throw new RuntimeException(modification + " is not a Polymer, ReferenceGroup or EntitySet"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceTherapeutic.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | import java.util.List; 7 | 8 | @Node 9 | public class ReferenceTherapeutic extends ReferenceEntity{ 10 | 11 | @ReactomeProperty 12 | private String abbreviation; 13 | @ReactomeProperty 14 | private List approvalSource; 15 | @ReactomeProperty 16 | private Boolean approved; 17 | @ReactomeProperty 18 | private String inn; 19 | @ReactomeProperty 20 | private String type; 21 | 22 | public ReferenceTherapeutic() { 23 | super(); 24 | this.setMoleculeType("ChemicalDrug"); 25 | } 26 | 27 | public String getAbbreviation() { 28 | return abbreviation; 29 | } 30 | 31 | public void setAbbreviation(String abbreviation) { 32 | this.abbreviation = abbreviation; 33 | } 34 | 35 | public List getApprovalSource() { 36 | return approvalSource; 37 | } 38 | 39 | public void setApprovalSource(List approvalSource) { 40 | this.approvalSource = approvalSource; 41 | } 42 | 43 | public Boolean getApproved() { 44 | return approved; 45 | } 46 | 47 | public void setApproved(Boolean approved) { 48 | this.approved = approved; 49 | } 50 | 51 | public String getInn() { 52 | return inn; 53 | } 54 | 55 | public void setInn(String inn) { 56 | this.inn = inn; 57 | } 58 | 59 | public String getType() { 60 | return type; 61 | } 62 | 63 | public void setType(String type) { 64 | this.type = type; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/UpdateTracker.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.reactome.server.graph.domain.annotations.ReactomeRelationship; 6 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 7 | import org.springframework.data.neo4j.core.schema.Node; 8 | import org.springframework.data.neo4j.core.schema.Relationship; 9 | 10 | import java.util.List; 11 | 12 | @Node 13 | public class UpdateTracker extends MetaDatabaseObject { 14 | 15 | @ReactomeProperty 16 | private List action; 17 | 18 | @Relationship(type = "release") 19 | @ReactomeRelationship(originName = "_release") 20 | private Release release; 21 | 22 | @Relationship(type = "updatedInstance") 23 | private List updatedInstance; 24 | 25 | public UpdateTracker() { 26 | } 27 | 28 | public Release getRelease() { 29 | return release; 30 | } 31 | 32 | public void setRelease(Release release) { 33 | this.release = release; 34 | } 35 | 36 | public List getAction() { 37 | return action; 38 | } 39 | 40 | public void setAction(List action) { 41 | this.action = action; 42 | } 43 | 44 | public List getUpdatedInstance() { 45 | return updatedInstance; 46 | } 47 | 48 | public void setUpdatedInstance(List updatedInstance) { 49 | this.updatedInstance = updatedInstance; 50 | } 51 | 52 | @ReactomeSchemaIgnore 53 | @Override 54 | @JsonIgnore 55 | public String getExplanation() { 56 | //todo 57 | return "updateTracker"; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/DiagramService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.result.DiagramOccurrences; 4 | import org.reactome.server.graph.domain.result.DiagramResult; 5 | import org.reactome.server.graph.repository.DiagramRepository; 6 | import org.reactome.server.graph.service.util.DatabaseObjectUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.Collection; 11 | 12 | /** 13 | * 14 | */ 15 | @Service 16 | public class DiagramService { 17 | 18 | @Autowired 19 | private DiagramRepository diagramRepository; 20 | 21 | public DiagramResult getDiagramResult(Object identifier) { 22 | String id = DatabaseObjectUtils.getIdentifier(identifier); 23 | if (DatabaseObjectUtils.isStId(id)) { 24 | return diagramRepository.getDiagramResult(id); 25 | } else if (DatabaseObjectUtils.isDbId(id)) { 26 | return diagramRepository.getDiagramResult(Long.parseLong(id)); 27 | } 28 | return null; 29 | } 30 | 31 | public Collection getDiagramOccurrences(Object identifier) { 32 | String id = DatabaseObjectUtils.getIdentifier(identifier); 33 | if (DatabaseObjectUtils.isStId(id)) { 34 | return diagramRepository.getDiagramOccurrences(id); 35 | } else if (DatabaseObjectUtils.isDbId(id)) { 36 | return diagramRepository.getDiagramOccurrences(Long.parseLong(id)); 37 | } 38 | return null; 39 | } 40 | 41 | public Collection getDiagramOccurrencesOfReferenceEntity(Long dbId) { 42 | return diagramRepository.getDiagramOccurrencesOfReferenceEntity(dbId); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Reaction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 5 | import org.springframework.data.neo4j.core.schema.Node; 6 | import org.springframework.data.neo4j.core.schema.Relationship; 7 | 8 | /** 9 | * Defines a change of state for one or more molecular entities. Most reactions in Reactome involve either: a) the interaction of entities to form a complex, or b) the movement of entities between compartments, or c) the chemical conversion of entities as part of a metabolic process. Reactions have a molecular balance between input and output entities. 10 | */ 11 | @SuppressWarnings("unused") 12 | @Node 13 | public class Reaction extends ReactionLikeEvent { 14 | 15 | @Relationship(type = "reverseReaction") 16 | private Reaction reverseReaction; 17 | 18 | public Reaction() {} 19 | 20 | public Reaction(Long dbId) { 21 | super(dbId); 22 | } 23 | 24 | public Reaction getReverseReaction() { 25 | return reverseReaction; 26 | } 27 | 28 | public void setReverseReaction(Reaction reverseReaction) { 29 | this.reverseReaction = reverseReaction; 30 | } 31 | 32 | @ReactomeSchemaIgnore 33 | @Override 34 | @JsonIgnore 35 | public String getExplanation() { 36 | return "Defines a change of state for one or more molecular entities. " + 37 | "Most reactions in Reactome involve either a) the interaction of entities to form a complex, or b) the movement of entities between compartments, or c) the chemical conversion of entities as part of a metabolic process. Reactions have a molecular balance between input and output entities"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/aop/LoggingAspect.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.aop; 2 | 3 | import org.aspectj.lang.ProceedingJoinPoint; 4 | import org.aspectj.lang.annotation.Around; 5 | import org.aspectj.lang.annotation.Aspect; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.stereotype.Component; 9 | 10 | /** 11 | * Created by: 12 | * 13 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 14 | * @since 19.11.15. 15 | * 16 | * Logging aspect, used for logging all methods in the service level. 17 | */ 18 | @Aspect 19 | @Component 20 | public class LoggingAspect { 21 | 22 | private static final Logger logger = LoggerFactory.getLogger(LoggingAspect.class); 23 | 24 | /** 25 | * Logging around all Service Methods to see execution times 26 | * @param joinPoint loggingPointcut 27 | * @return Object returned by the method currently logged around 28 | * @throws Throwable exception when executing service methods 29 | */ 30 | @Around("execution(public * org.reactome.server.graph.service.*.*(..))") 31 | public Object monitorExecutionTimes(ProceedingJoinPoint joinPoint) throws Throwable { 32 | long start = System.currentTimeMillis(); 33 | Object result = joinPoint.proceed(); 34 | long elapsedTime = System.currentTimeMillis() - start; 35 | int milliseconds = (int) elapsedTime % 1000; 36 | int seconds = (int) (elapsedTime / 1000) % 60; 37 | int minutes = (int) ((elapsedTime / (1000 * 60)) % 60); 38 | logger.debug(joinPoint.getSignature().getDeclaringType().getSimpleName() + ":" + joinPoint.getSignature().getName() + 39 | " successfully executed in " + minutes + " min " + seconds + " sec " + milliseconds + " mil"); 40 | return result; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/OrthologyService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | import org.reactome.server.graph.repository.OrthologyRepository; 5 | import org.reactome.server.graph.service.util.DatabaseObjectUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Collection; 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @Service 14 | @SuppressWarnings("WeakerAccess") 15 | public class OrthologyService { 16 | 17 | private final OrthologyRepository orthologyRepository; 18 | 19 | @Autowired 20 | public OrthologyService(OrthologyRepository orthologyRepository) { 21 | this.orthologyRepository = orthologyRepository; 22 | } 23 | 24 | public Collection getOrthology(Object identifier, Long speciesId){ 25 | String id = DatabaseObjectUtils.getIdentifier(identifier); 26 | if (DatabaseObjectUtils.isStId(id)) { 27 | return orthologyRepository.getOrthology(id, speciesId); 28 | } else if (DatabaseObjectUtils.isDbId(id)){ 29 | return orthologyRepository.getOrthology(Long.parseLong(id), speciesId); 30 | } 31 | return null; 32 | } 33 | 34 | public Map> getOrthologies(Collection identifiers, Long speciesId){ 35 | Map> rtn = new HashMap<>(); 36 | for (Object identifier : identifiers) { 37 | Collection orthology = getOrthology(identifier, speciesId); 38 | if(orthology != null){ 39 | rtn.put(identifier, orthology); 40 | } 41 | } 42 | return rtn; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | %d %-5level [@project.name@ - logback] [%thread] %logger{0}: %msg%n 11 | 12 | 13 | 14 | 15 | logging.dir}/graph/graph-core.log 16 | 17 | @logging.dir@/graph/graph-%i-log.zip 18 | 1 19 | 3 20 | 21 | 23 | 10MB 24 | 25 | 26 | %d %-5level [@project.name@ - logback] [%thread] %class{36} %logger{0}: %msg%n 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/ReferenceEntityRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.ReferenceEntity; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | 11 | @Repository 12 | public interface ReferenceEntityRepository extends Neo4jRepository { 13 | 14 | @Query(" MATCH (rd:ReferenceDatabase)<--(n{identifier:$identifier})<-[:referenceEntity|referenceSequence|crossReference|referenceGene*]-(pe:PhysicalEntity) " + 15 | "WITH DISTINCT pe " + 16 | "MATCH (pe)-[:referenceEntity]->(n:ReferenceEntity)" + 17 | "RETURN DISTINCT n") 18 | Collection getReferenceEntitiesFor(@Param("identifier") String identifier); 19 | 20 | @Query(" MATCH (n:DatabaseObject{dbId:$dbId})-[:hasEvent|input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|regulatedBy|regulator|hasComponent|hasMember|hasCandidate|repeatedUnit|referenceEntity|proteinMarker|RNAMarker*]->(m:ReferenceEntity) " + 21 | "RETURN DISTINCT m") 22 | Collection getParticipatingReferenceEntities(@Param("dbId") Long dbId); 23 | 24 | @Query(" MATCH (n:DatabaseObject{stId:$stId})-[:hasEvent|input|output|catalystActivity|physicalEntity|entityFunctionalStatus|diseaseEntity|regulatedBy|regulator|hasComponent|hasMember|hasCandidate|repeatedUnit|referenceEntity|proteinMarker|RNAMarker*]->(m:ReferenceEntity) " + 25 | "RETURN DISTINCT m") 26 | Collection getParticipatingReferenceEntities(@Param("stId") String stId); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GO_CellularComponent.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.springframework.data.neo4j.core.schema.Node; 4 | import org.springframework.data.neo4j.core.schema.Relationship; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings("unused") 9 | @Node 10 | public class GO_CellularComponent extends GO_Term { 11 | 12 | @Relationship(type = "componentOf") 13 | private List componentOf; 14 | 15 | @Relationship(type = "hasPart") 16 | private List hasPart; 17 | 18 | @Relationship(type = "instanceOf") 19 | private List instanceOf; 20 | 21 | @Relationship(type = "surroundedBy") 22 | private List surroundedBy; 23 | 24 | public GO_CellularComponent() {} 25 | 26 | public GO_CellularComponent(Long dbId) { 27 | super(dbId); 28 | } 29 | 30 | public List getComponentOf() { 31 | return componentOf; 32 | } 33 | 34 | public void setComponentOf(List componentOf) { 35 | this.componentOf = componentOf; 36 | } 37 | 38 | public List getHasPart() { 39 | return hasPart; 40 | } 41 | 42 | public void setHasPart(List hasPart) { 43 | this.hasPart = hasPart; 44 | } 45 | 46 | public List getInstanceOf() { 47 | return instanceOf; 48 | } 49 | 50 | public void setInstanceOf(List instanceOf) { 51 | this.instanceOf = instanceOf; 52 | } 53 | 54 | public List getSurroundedBy() { 55 | return surroundedBy; 56 | } 57 | 58 | public void setSurroundedBy(List surroundedBy) { 59 | this.surroundedBy = surroundedBy; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/CompartmentTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.reactome.server.graph.domain.model.Compartment; 5 | import org.reactome.server.graph.domain.model.ReactionLikeEvent; 6 | import org.reactome.server.graph.util.DatabaseObjectFactory; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.event.annotation.BeforeTestClass; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertEquals; 12 | 13 | @SpringBootTest 14 | public class CompartmentTest extends BaseTest{ 15 | 16 | @Autowired 17 | private DatabaseObjectService databaseObjectService; 18 | 19 | @BeforeTestClass 20 | public void setUpClass() { 21 | logger.info(" --- !!! Running " + CompartmentTest.class.getName() + " !!! --- \n"); 22 | } 23 | 24 | @Test 25 | public void findCompartmentList() { 26 | logger.info("Started testing compartmentTest.findCompartmentList"); 27 | 28 | long start, time; 29 | start = System.currentTimeMillis(); 30 | ReactionLikeEvent rleGDB = databaseObjectService.findById("1247999"); 31 | ReactionLikeEvent rleRDB = DatabaseObjectFactory.createObject("1247999"); 32 | 33 | assertEquals(rleRDB.getCompartment().size(), rleGDB.getCompartment().size(), "Different sizes"); 34 | 35 | for (int i = 0; i < rleRDB.getCompartment().size(); i++) { 36 | Compartment cRDB = rleRDB.getCompartment().get(i); 37 | Compartment cGDB = rleGDB.getCompartment().get(i); 38 | assertEquals(cGDB, cRDB, cGDB + " differs of " + cRDB); 39 | } 40 | 41 | time = System.currentTimeMillis() - start; 42 | logger.info("Comparison execution time: " + time + "ms"); 43 | 44 | logger.info("Finished"); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/helper/AttributeProperties.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service.helper; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | import org.springframework.lang.NonNull; 5 | 6 | import java.util.Comparator; 7 | import java.util.LinkedList; 8 | import java.util.List; 9 | 10 | /** 11 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 12 | */ 13 | @SuppressWarnings("unused") 14 | public class AttributeProperties implements Comparable { 15 | 16 | private String name; 17 | private String cardinality; 18 | private final List attributeClasses = new LinkedList<>(); 19 | private Class origin; 20 | private static final Comparator comparator = Comparator 21 | .comparing(AttributeProperties::getName) 22 | .thenComparing(attr -> attr.getOrigin().getName()); 23 | 24 | public String getName() { 25 | return name; 26 | } 27 | 28 | public void setName(String name) { 29 | this.name = name; 30 | } 31 | 32 | public String getCardinality() { 33 | return cardinality; 34 | } 35 | 36 | public void setCardinality(String cardinality) { 37 | this.cardinality = cardinality; 38 | } 39 | 40 | public List getAttributeClasses() { 41 | return attributeClasses; 42 | } 43 | 44 | public void addAttributeClass(Class valueType) { 45 | this.attributeClasses.add(new AttributeClass(valueType)); 46 | } 47 | 48 | public Class getOrigin() { 49 | return origin; 50 | } 51 | 52 | public void setOrigin(Class origin) { 53 | this.origin = origin; 54 | } 55 | 56 | @Override 57 | public int compareTo(@NonNull AttributeProperties o) { 58 | return comparator.compare(this, o); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/helper/ContentDetails.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service.helper; 2 | 3 | import org.reactome.server.graph.domain.model.DatabaseObject; 4 | import org.reactome.server.graph.domain.model.PhysicalEntity; 5 | import org.reactome.server.graph.domain.result.ComponentOf; 6 | 7 | import java.util.Collection; 8 | import java.util.Set; 9 | 10 | /** 11 | * Created by: 12 | * 13 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 14 | * @since 14.04.16. 15 | */ 16 | public class ContentDetails { 17 | 18 | private DatabaseObject databaseObject; 19 | private Set nodes; 20 | private Collection componentOf; 21 | private Collection otherFormsOfThisMolecule; 22 | 23 | public ContentDetails() {} 24 | 25 | public Collection getComponentOf() { 26 | return componentOf; 27 | } 28 | 29 | public void setComponentOf(Collection componentOfs) { 30 | // TODO sorting is not working as the list is unmodifiable 31 | // componentOfs.forEach(ComponentOf::sortByName); 32 | this.componentOf = componentOfs; 33 | } 34 | 35 | public DatabaseObject getDatabaseObject() { 36 | return databaseObject; 37 | } 38 | 39 | public void setDatabaseObject(DatabaseObject databaseObject) { 40 | this.databaseObject = databaseObject; 41 | } 42 | 43 | public Set getNodes() { 44 | return nodes; 45 | } 46 | 47 | public void setNodes(Set nodes) { 48 | this.nodes = nodes; 49 | } 50 | 51 | public Collection getOtherFormsOfThisMolecule() { 52 | return otherFormsOfThisMolecule; 53 | } 54 | 55 | public void setOtherFormsOfThisMolecule(Collection otherFormsOfThisMolecule) { 56 | this.otherFormsOfThisMolecule = otherFormsOfThisMolecule; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/result/PersonAuthorReviewer.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.result; 2 | 3 | import org.reactome.server.graph.domain.model.Person; 4 | 5 | public class PersonAuthorReviewer { 6 | 7 | private Person person; 8 | private Long authoredPathways; 9 | private Long reviewedPathways; 10 | private Long authoredReactions; 11 | private Long reviewedReactions; 12 | 13 | public PersonAuthorReviewer(Person person, Long authoredPathways, Long reviewedPathways, Long authoredReactions, Long reviewedReactions) { 14 | this.person = person; 15 | this.authoredPathways = authoredPathways; 16 | this.reviewedPathways = reviewedPathways; 17 | this.authoredReactions = authoredReactions; 18 | this.reviewedReactions = reviewedReactions; 19 | } 20 | 21 | public Person getPerson() { 22 | return person; 23 | } 24 | 25 | public Long getAuthoredPathways() { 26 | return authoredPathways; 27 | } 28 | 29 | public Long getReviewedPathways() { 30 | return reviewedPathways; 31 | } 32 | 33 | public Long getAuthoredReactions() { 34 | return authoredReactions; 35 | } 36 | 37 | public Long getReviewedReactions() { 38 | return reviewedReactions; 39 | } 40 | 41 | public void setPerson(Person person) { 42 | this.person = person; 43 | } 44 | 45 | public void setAuthoredPathways(Long authoredPathways) { 46 | this.authoredPathways = authoredPathways; 47 | } 48 | 49 | public void setReviewedPathways(Long reviewedPathways) { 50 | this.reviewedPathways = reviewedPathways; 51 | } 52 | 53 | public void setAuthoredReactions(Long authoredReactions) { 54 | this.authoredReactions = authoredReactions; 55 | } 56 | 57 | public void setReviewedReactions(Long reviewedReactions) { 58 | this.reviewedReactions = reviewedReactions; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/AdvancedLinkageServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.reactome.server.graph.domain.result.ComponentOf; 5 | import org.reactome.server.graph.domain.result.Referrals; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.test.context.event.annotation.BeforeTestClass; 8 | 9 | import java.util.Collection; 10 | 11 | import static org.junit.jupiter.api.Assertions.assertTrue; 12 | 13 | 14 | public class AdvancedLinkageServiceTest extends BaseTest { 15 | 16 | @Autowired 17 | private AdvancedLinkageService advancedLinkageService; 18 | 19 | @BeforeTestClass 20 | public void setUpClass() { 21 | logger.info(" --- !!! Running " + AdvancedLinkageServiceTest.class.getName() + "!!! --- \n"); 22 | } 23 | 24 | @Test 25 | public void getComponentsOfTest() { 26 | logger.info("Started testing genericService.getComponentsOfTest"); 27 | long start, time; 28 | start = System.currentTimeMillis(); 29 | Collection componentOfs = advancedLinkageService.getComponentsOf("R-HSA-199420"); 30 | time = System.currentTimeMillis() - start; 31 | logger.info("GraphDb execution time: " + time + "ms"); 32 | 33 | assertTrue(componentOfs.size() > 0); 34 | logger.info("Finished"); 35 | } 36 | 37 | @Test 38 | public void getReferralsToTest(){ 39 | logger.info("Started testing genericService.getReferralsToTest"); 40 | long start, time; 41 | start = System.currentTimeMillis(); 42 | Collection referrals = advancedLinkageService.getReferralsTo("R-HSA-71291"); 43 | time = System.currentTimeMillis() - start; 44 | logger.info("GraphDb execution time: " + time + "ms"); 45 | 46 | assertTrue(referrals.size() >= 1, "There has to be 2 or more referrals"); 47 | logger.info("Finished"); 48 | } 49 | } -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/TopLevelPathwayRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.model.TopLevelPathway; 4 | import org.springframework.data.neo4j.repository.Neo4jRepository; 5 | import org.springframework.data.neo4j.repository.query.Query; 6 | import org.springframework.data.repository.query.Param; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | 11 | @Repository 12 | public interface TopLevelPathwayRepository extends Neo4jRepository { 13 | 14 | @Query("MATCH (n:TopLevelPathway{isInferred:False}) RETURN n ORDER BY toLower(n.displayName)") 15 | Collection getTopLevelPathways(); 16 | 17 | @Query("MATCH (n:TopLevelPathway)-[r:species]-(s:Species{displayName:$speciesName}) RETURN n, collect(r), collect(s) ORDER BY toLower(n.displayName) ASC") 18 | Collection getTopLevelPathwaysByName(@Param("speciesName") String speciesName); 19 | 20 | @Query("MATCH (n:TopLevelPathway)-[r:species]-(s:Species{taxId:$taxId}) RETURN n, collect(r), collect(s) ORDER BY toLower(n.displayName) ASC") 21 | Collection getTopLevelPathwaysByTaxId(@Param("taxId") String taxId); 22 | 23 | @Query("MATCH (n:TopLevelPathway{isInferred:False}) RETURN n ORDER BY toLower(n.displayName)") 24 | Collection getCuratedTopLevelPathways(); 25 | 26 | @Query("MATCH (n:TopLevelPathway{isInferred:False})-[r:species]-(s:Species{displayName:$speciesName}) RETURN n, collect(r), collect(s) ORDER BY toLower(n.displayName)") 27 | Collection getCuratedTopLevelPathwaysByName(@Param("speciesName") String speciesName); 28 | 29 | @Query("MATCH (n:TopLevelPathway{isInferred:False})-[r:species]-(s:Species{taxId:$taxId}) RETURN n, collect(r), collect(s) ORDER BY toLower(n.displayName)") 30 | Collection getCuratedTopLevelPathwaysByTaxId(@Param("taxId") String taxId); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DatabaseIdentifier.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings("unused") 10 | @Node 11 | public class DatabaseIdentifier extends DatabaseObject { 12 | 13 | // will be filled together with url 14 | private String databaseName; 15 | @ReactomeProperty 16 | private String identifier; 17 | @ReactomeProperty(addedField = true) 18 | private String url; 19 | 20 | @Relationship(type = "crossReference") 21 | private List crossReference; 22 | 23 | @Relationship(type = "referenceDatabase") 24 | private ReferenceDatabase referenceDatabase; 25 | 26 | public DatabaseIdentifier() {} 27 | 28 | public String getDatabaseName() { 29 | return databaseName; 30 | } 31 | 32 | public void setDatabaseName(String databaseName) { 33 | this.databaseName = databaseName; 34 | } 35 | 36 | public String getIdentifier() { 37 | return identifier; 38 | } 39 | 40 | public void setIdentifier(String identifier) { 41 | this.identifier = identifier; 42 | } 43 | 44 | public String getUrl() { 45 | return url; 46 | } 47 | 48 | public void setUrl(String url) { 49 | this.url = url; 50 | } 51 | 52 | public List getCrossReference() { 53 | return crossReference; 54 | } 55 | 56 | public void setCrossReference(List crossReference) { 57 | this.crossReference = crossReference; 58 | } 59 | 60 | public ReferenceDatabase getReferenceDatabase() { 61 | return referenceDatabase; 62 | } 63 | 64 | public void setReferenceDatabase(ReferenceDatabase referenceDatabase) { 65 | this.referenceDatabase = referenceDatabase; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/LiteratureReference.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | @SuppressWarnings("unused") 7 | @Node 8 | public class LiteratureReference extends Publication { 9 | 10 | private static final transient String PUBMED_URL = "http://www.ncbi.nlm.nih.gov/pubmed/"; 11 | 12 | @ReactomeProperty 13 | private String journal; 14 | @ReactomeProperty 15 | private String pages; 16 | @ReactomeProperty 17 | private Integer pubMedIdentifier; 18 | @ReactomeProperty 19 | private Integer volume; 20 | @ReactomeProperty 21 | private Integer year; 22 | 23 | public LiteratureReference() {} 24 | 25 | public LiteratureReference(Long dbId) { 26 | super(dbId); 27 | } 28 | 29 | public String getJournal() { 30 | return this.journal; 31 | } 32 | 33 | public void setJournal(String journal) { 34 | this.journal = journal; 35 | } 36 | 37 | public String getPages() { 38 | return this.pages; 39 | } 40 | 41 | public void setPages(String pages) { 42 | this.pages = pages; 43 | } 44 | 45 | public Integer getPubMedIdentifier() { 46 | return this.pubMedIdentifier; 47 | } 48 | 49 | public void setPubMedIdentifier(Integer pubMedIdentifier) { 50 | this.pubMedIdentifier = pubMedIdentifier; 51 | } 52 | 53 | public Integer getVolume() { 54 | return this.volume; 55 | } 56 | 57 | public void setVolume(Integer volume) { 58 | this.volume = volume; 59 | } 60 | 61 | public Integer getYear() { 62 | return this.year; 63 | } 64 | 65 | public void setYear(Integer year) { 66 | this.year = year; 67 | } 68 | 69 | public String getUrl() { 70 | if (pubMedIdentifier != null) { 71 | return PUBMED_URL + pubMedIdentifier; 72 | } 73 | return null; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/service/BaseTest.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.junit.jupiter.api.BeforeEach; 4 | import org.reactome.server.graph.aop.LazyFetchAspect; 5 | import org.reactome.server.graph.util.DatabaseObjectFactory; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.data.neo4j.core.Neo4jClient; 11 | import org.springframework.test.context.event.annotation.AfterTestClass; 12 | 13 | import static org.junit.jupiter.api.Assumptions.assumeTrue; 14 | 15 | /** 16 | * @author Guilherme S Viteri 17 | */ 18 | @SpringBootTest 19 | public abstract class BaseTest { 20 | 21 | protected static final Logger logger = LoggerFactory.getLogger("testLogger"); 22 | 23 | static Boolean checkedOnce = false; 24 | static Boolean isFit = false; 25 | 26 | @Autowired 27 | protected Neo4jClient neo4jClient; 28 | 29 | @Autowired 30 | protected LazyFetchAspect lazyFetchAspect; 31 | 32 | @AfterTestClass 33 | public void tearDownClass() { 34 | logger.info("\n\n"); 35 | } 36 | 37 | @BeforeEach 38 | public void setUp() throws Exception { 39 | if (!checkedOnce) { 40 | isFit = fitForService(); 41 | checkedOnce = true; 42 | } 43 | 44 | /* DISABLING LAZY LOADING FOR A PROPER TESTING */ 45 | lazyFetchAspect.setEnableAOP(false); 46 | 47 | assumeTrue(isFit); 48 | DatabaseObjectFactory.clearCache(); 49 | } 50 | 51 | protected final boolean fitForService() { 52 | String query = "MATCH (n) RETURN COUNT(n) > 0 AS fitForService"; 53 | try { 54 | return neo4jClient.query(query).fetchAs(Boolean.class).first().orElse(false); 55 | } catch (Exception e) { 56 | logger.error("A connection with the Neo4j Graph could not be established. Tests will be skipped", e); 57 | } 58 | return false; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/TopLevelPathwayService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | import org.reactome.server.graph.domain.model.TopLevelPathway; 5 | import org.reactome.server.graph.repository.TopLevelPathwayRepository; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.Collection; 10 | 11 | /** 12 | * Created by: 13 | * 14 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 15 | * @since 18.05.16. 16 | */ 17 | @Service 18 | @SuppressWarnings("WeakerAccess") 19 | public class TopLevelPathwayService { 20 | 21 | public final TopLevelPathwayRepository topLevelPathwayRepository; 22 | 23 | @Autowired 24 | public TopLevelPathwayService(TopLevelPathwayRepository topLevelPathwayRepository) { 25 | this.topLevelPathwayRepository = topLevelPathwayRepository; 26 | } 27 | 28 | public Collection getTopLevelPathways() { 29 | return topLevelPathwayRepository.getTopLevelPathways(); 30 | } 31 | 32 | public Collection getTopLevelPathways(Object species) { 33 | String speciesString = species.toString(); 34 | if (StringUtils.isNumeric(speciesString)) { 35 | return topLevelPathwayRepository.getTopLevelPathwaysByTaxId(speciesString); 36 | } else { 37 | return topLevelPathwayRepository.getTopLevelPathwaysByName(speciesString); 38 | } 39 | } 40 | 41 | public Collection getCuratedTopLevelPathways() { 42 | return topLevelPathwayRepository.getCuratedTopLevelPathways(); 43 | } 44 | 45 | public Collection getCuratedTopLevelPathways(Object species) { 46 | String speciesString = species.toString(); 47 | if (StringUtils.isNumeric(speciesString)) { 48 | return topLevelPathwayRepository.getCuratedTopLevelPathwaysByTaxId(speciesString); 49 | } else { 50 | return topLevelPathwayRepository.getCuratedTopLevelPathwaysByName(speciesString); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/org/reactome/server/graph/custom/CustomQueryResult.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.custom; 2 | 3 | import org.neo4j.driver.Record; 4 | import org.neo4j.driver.Value; 5 | import org.reactome.server.graph.domain.result.CustomQuery; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Custom object used to test the custom queries methods 11 | * 12 | * @author Guilherme S Viteri 13 | */ 14 | @SuppressWarnings("unused") 15 | public class CustomQueryResult implements CustomQuery { 16 | private Long dbId; 17 | private String name; 18 | private List events; 19 | private String[] eventsArray; 20 | private int[] eventsPrimitiveArray; 21 | 22 | public Long getDbId() { 23 | return dbId; 24 | } 25 | 26 | public void setDbId(Long dbId) { 27 | this.dbId = dbId; 28 | } 29 | 30 | public String getName() { 31 | return name; 32 | } 33 | 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | 38 | public List getEvents() { 39 | return events; 40 | } 41 | 42 | public void setEvents(List events) { 43 | this.events = events; 44 | } 45 | 46 | public String[] getEventsArray() { 47 | return eventsArray; 48 | } 49 | 50 | public void setEventsArray(String[] eventsArray) { 51 | this.eventsArray = eventsArray; 52 | } 53 | 54 | public int[] getEventsPrimitiveArray() { 55 | return eventsPrimitiveArray; 56 | } 57 | 58 | public void setEventsPrimitiveArray(int[] eventsPrimitiveArray) { 59 | this.eventsPrimitiveArray = eventsPrimitiveArray; 60 | } 61 | 62 | @Override 63 | public CustomQuery build(Record r) { 64 | this.setDbId(r.get("dbId").asLong()); 65 | this.setName(r.get("name").asString()); 66 | this.setEvents(r.get("events").asList(Value::asLong)); 67 | this.setEventsArray(r.get("eventsArray").asList(Value::asString).toArray(new String[0])); 68 | this.setEventsPrimitiveArray(r.get("eventsPrimitiveArray").asList(Value::asInt).stream().mapToInt(Integer::intValue).toArray()); 69 | return this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/repository/CustomInteractionsRepository.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.repository; 2 | 3 | import org.reactome.server.graph.domain.result.CustomInteraction; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.data.neo4j.core.Neo4jClient; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.Collection; 10 | import java.util.Collections; 11 | 12 | @Repository 13 | public class CustomInteractionsRepository { 14 | 15 | private final Neo4jClient neo4jClient; 16 | 17 | @Value("${spring.data.neo4j.database:graph.db}") 18 | private String databaseName; 19 | 20 | @Autowired 21 | public CustomInteractionsRepository(Neo4jClient neo4jClient) { 22 | this.neo4jClient = neo4jClient; 23 | } 24 | 25 | public Collection getCustomInteractionsByAcc(String identifier) { 26 | //language=cypher 27 | String query = 28 | "MATCH (t:ReferenceEntity)<-[:interactor]-(in:Interaction)-[ir:interactor]->(re:ReferenceEntity) " + 29 | "WHERE t.variantIdentifier = $identifier OR (t.variantIdentifier IS NULL AND t.identifier = $identifier) " + 30 | "OPTIONAL MATCH (pe:PhysicalEntity)-[r:referenceEntity]->(re) " + 31 | "OPTIONAL MATCH (se:Species)<-[s:species]-(re) " + 32 | "WITH in, re, se, pe, t " + 33 | "ORDER BY in.score DESC " + 34 | "RETURN DISTINCT in.dbId AS dbId, in.score AS score, SIZE(in.accession) AS evidenceCount, re.identifier AS identifier, re.databaseName AS databaseName, re.displayName AS displayName, re.variantIdentifier as variantIdentifier, re.geneName AS geneName, re.url as url, in.url AS evidenceURL, se.displayName AS speciesName, COUNT(pe) AS entitiesCount"; 35 | 36 | return neo4jClient.query(query).in(databaseName).bindAll(Collections.singletonMap("identifier", identifier)).fetchAs(CustomInteraction.class).mappedBy((typeSystem, record) -> new CustomInteraction(record)).all(); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/DeletedInstance.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 5 | import org.reactome.server.graph.domain.annotations.ReactomeSchemaIgnore; 6 | import org.springframework.data.neo4j.core.schema.Node; 7 | import org.springframework.data.neo4j.core.schema.Relationship; 8 | 9 | import java.util.List; 10 | 11 | @Node 12 | public class DeletedInstance extends MetaDatabaseObject { 13 | 14 | @ReactomeProperty(originName = "class") 15 | private String clazz; 16 | 17 | @ReactomeProperty(originName = "deletedInstanceDB_ID") 18 | private Integer deletedInstanceDbId; 19 | 20 | @ReactomeProperty 21 | private String name; 22 | 23 | @ReactomeProperty(addedField = true) 24 | private String deletedStId; 25 | 26 | @Relationship(type = "species") 27 | private List species; 28 | 29 | public DeletedInstance() { 30 | } 31 | 32 | public String getClazz() { 33 | return clazz; 34 | } 35 | 36 | public void setClazz(String clazz) { 37 | this.clazz = clazz; 38 | } 39 | 40 | public Integer getDeletedInstanceDbId() { 41 | return deletedInstanceDbId; 42 | } 43 | 44 | public void setDeletedInstanceDbId(Integer deletedInstanceDbId) { 45 | this.deletedInstanceDbId = deletedInstanceDbId; 46 | } 47 | 48 | public String getDeletedStId() { 49 | return deletedStId; 50 | } 51 | 52 | public void setDeletedStId(String deletedStId) { 53 | this.deletedStId = deletedStId; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public void setName(String name) { 61 | this.name = name; 62 | } 63 | 64 | public List getSpecies() { 65 | return species; 66 | } 67 | 68 | public void setSpecies(List species) { 69 | this.species = species; 70 | } 71 | 72 | @ReactomeSchemaIgnore 73 | @Override 74 | @JsonIgnore 75 | public String getExplanation() { 76 | //todo 77 | return "DeletedInstance"; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/Interaction.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | import java.util.List; 8 | 9 | @SuppressWarnings({"unused", "WeakerAccess"}) 10 | @Node 11 | public abstract class Interaction extends DatabaseObject { 12 | 13 | @Relationship(type = "referenceDatabase") 14 | private ReferenceDatabase referenceDatabase; 15 | @ReactomeProperty 16 | private String databaseName; 17 | @ReactomeProperty 18 | private Double score; 19 | @ReactomeProperty 20 | private List accession; 21 | @ReactomeProperty 22 | private List pubmed; 23 | @ReactomeProperty 24 | private String url; 25 | 26 | // private List type; 27 | // private String expansionType; //spokeExpansion 28 | 29 | public Interaction() { } 30 | 31 | public ReferenceDatabase getReferenceDatabase() { 32 | return referenceDatabase; 33 | } 34 | 35 | public void setReferenceDatabase(ReferenceDatabase referenceDatabase) { 36 | this.referenceDatabase = referenceDatabase; 37 | } 38 | 39 | public String getDatabaseName() { 40 | return databaseName; 41 | } 42 | 43 | public void setDatabaseName(String databaseName) { 44 | this.databaseName = databaseName; 45 | } 46 | 47 | public Double getScore() { 48 | return score; 49 | } 50 | 51 | public void setScore(Double score) { 52 | this.score = score; 53 | } 54 | 55 | public List getAccession() { 56 | return accession; 57 | } 58 | 59 | public void setAccession(List accession) { 60 | this.accession = accession; 61 | } 62 | 63 | public List getPubmed() { 64 | return pubmed; 65 | } 66 | 67 | public void setPubmed(List pubmed) { 68 | this.pubmed = pubmed; 69 | } 70 | 71 | public String getUrl() { 72 | return url; 73 | } 74 | 75 | public void setUrl(String url) { 76 | this.url = url; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/service/AdvancedLinkageService.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.service; 2 | 3 | import org.reactome.server.graph.domain.result.ComponentOf; 4 | import org.reactome.server.graph.domain.result.Referrals; 5 | import org.reactome.server.graph.repository.AdvancedLinkageRepository; 6 | import org.reactome.server.graph.repository.ComponentOfLinkageRepository; 7 | import org.reactome.server.graph.repository.ReferralsLinkageRepository; 8 | import org.reactome.server.graph.service.util.DatabaseObjectUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | 12 | import java.util.Collection; 13 | 14 | @Service 15 | public class AdvancedLinkageService { 16 | 17 | private AdvancedLinkageRepository advancedLinkageRepository; 18 | 19 | private final ComponentOfLinkageRepository componentOfLinkageRepository; 20 | private final ReferralsLinkageRepository referralsLinkageRepository; 21 | 22 | @Autowired 23 | public AdvancedLinkageService(ComponentOfLinkageRepository componentOfLinkageRepository, ReferralsLinkageRepository referralsLinkageRepository) { 24 | this.componentOfLinkageRepository = componentOfLinkageRepository; 25 | this.referralsLinkageRepository = referralsLinkageRepository; 26 | } 27 | 28 | public Collection getComponentsOf(Object identifier) { 29 | String id = DatabaseObjectUtils.getIdentifier(identifier); 30 | if (DatabaseObjectUtils.isStId(id)) { 31 | return componentOfLinkageRepository.getComponentsOf(id); 32 | } else if (DatabaseObjectUtils.isDbId(id)) { 33 | return componentOfLinkageRepository.getComponentsOf(Long.parseLong(id)); 34 | } 35 | return null; 36 | } 37 | 38 | public Collection getReferralsTo(Object identifier){ 39 | String id = DatabaseObjectUtils.getIdentifier(identifier); 40 | if (DatabaseObjectUtils.isStId(id)) { 41 | return referralsLinkageRepository.getReferralsTo(id); 42 | } else if (DatabaseObjectUtils.isDbId(id)) { 43 | return referralsLinkageRepository.getReferralsTo(Long.parseLong(id)); 44 | } 45 | return null; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/ReferenceDatabase.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | 6 | import java.util.List; 7 | 8 | @SuppressWarnings({"unused", "WeakerAccess"}) 9 | @Node 10 | public class ReferenceDatabase extends DatabaseObject { 11 | 12 | @ReactomeProperty 13 | private String accessUrl; 14 | @ReactomeProperty 15 | private List name; 16 | @ReactomeProperty 17 | private String url; 18 | @ReactomeProperty 19 | private String resourceIdentifier; 20 | /** 21 | * Prefix from identifiers.org registry used to link to the database in a standardized way. Should be populated as much as possible. 22 | */ 23 | @ReactomeProperty 24 | private String identifiersPrefix; 25 | 26 | public ReferenceDatabase() {} 27 | 28 | public String getAccessUrl() { 29 | return accessUrl; 30 | } 31 | 32 | public void setAccessUrl(String accessUrl) { 33 | this.accessUrl = accessUrl; 34 | } 35 | 36 | public List getName() { 37 | return name; 38 | } 39 | 40 | public void setName(List name) { 41 | this.name = name; 42 | } 43 | 44 | public String getUrl() { 45 | return url; 46 | } 47 | 48 | public void setUrl(String url) { 49 | this.url = url; 50 | } 51 | 52 | public String getResourceIdentifier() { 53 | return resourceIdentifier; 54 | } 55 | 56 | public void setResourceIdentifier(String resourceIdentifier) { 57 | this.resourceIdentifier = resourceIdentifier; 58 | } 59 | 60 | /** 61 | * Prefix from identifiers.org registry used to link to the database in a standardized way. Should be populated as much as possible. 62 | */ 63 | public String getIdentifiersPrefix() { 64 | return identifiersPrefix; 65 | } 66 | 67 | /** 68 | * Prefix from identifiers.org registry used to link to the database in a standardized way. Should be populated as much as possible. 69 | */ 70 | public void setIdentifiersPrefix(String identifiersPrefix) { 71 | this.identifiersPrefix = identifiersPrefix; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/reactome/server/graph/domain/model/GO_Term.java: -------------------------------------------------------------------------------- 1 | package org.reactome.server.graph.domain.model; 2 | 3 | import org.reactome.server.graph.domain.annotations.ReactomeProperty; 4 | import org.springframework.data.neo4j.core.schema.Node; 5 | import org.springframework.data.neo4j.core.schema.Relationship; 6 | 7 | /** 8 | * Created by: 9 | * 10 | * @author Florian Korninger (florian.korninger@ebi.ac.uk) 11 | * @since 14.04.16. 12 | */ 13 | @SuppressWarnings("unused") 14 | @Node 15 | public abstract class GO_Term extends DatabaseObject{ 16 | 17 | @ReactomeProperty 18 | private String accession; 19 | // will be filled together with url 20 | private String databaseName; 21 | @ReactomeProperty 22 | private String definition; 23 | @ReactomeProperty 24 | private String name; 25 | @ReactomeProperty(addedField = true) 26 | private String url; 27 | @Relationship(type = "referenceDatabase") 28 | private ReferenceDatabase referenceDatabase; 29 | 30 | public GO_Term() {} 31 | 32 | public GO_Term(Long dbId) { 33 | super(dbId); 34 | } 35 | 36 | public String getAccession() { 37 | return accession; 38 | } 39 | 40 | public void setAccession(String accession) { 41 | this.accession = accession; 42 | } 43 | 44 | public String getDatabaseName() { 45 | return databaseName; 46 | } 47 | 48 | public void setDatabaseName(String databaseName) { 49 | this.databaseName = databaseName; 50 | } 51 | 52 | public String getDefinition() { 53 | return definition; 54 | } 55 | 56 | public void setDefinition(String definition) { 57 | this.definition = definition; 58 | } 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | public void setName(String name) { 65 | this.name = name; 66 | } 67 | 68 | public String getUrl() { 69 | return url; 70 | } 71 | 72 | public void setUrl(String url) { 73 | this.url = url; 74 | } 75 | 76 | public ReferenceDatabase getReferenceDatabase() { 77 | return referenceDatabase; 78 | } 79 | 80 | public void setReferenceDatabase(ReferenceDatabase referenceDatabase) { 81 | this.referenceDatabase = referenceDatabase; 82 | } 83 | } 84 | 85 | --------------------------------------------------------------------------------