4.2.0 • Published 1 month ago

@rcsb/rcsb-api-tools v4.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

rcsb-api-tools

RCSB Saguaro Web API is an open-source library that includes different tools to validate and request data from the 1D Coordinate Server, the RCSB Data API and the RCSB Search Service.

Node Module Instalation

npm install @rcsb/rcsb-api-tools

Requesting RCSB GraphQL data

import {GraphQLRequest} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/GraphQLRequest"

const client = new GraphQLRequest("data-api"|"1d-coordinates"|url);

client.request(query_params, query_string);

Example

query_params
const query_params = {
  queryId: "P01112",
  from: "UNIPROT",
  to: "PDB_ENTITY"
}
query_string
query QueryAlignment($queryId: String!, $from: String!, $to: String!, $range:[Int!]){
     alignment(
         queryId:$queryId
         from:$from
         to:$to
         range:$range
     ){
         query_sequence
         target_alignment {
             target_id
             orientation
             target_sequence
             coverage {
                 query_coverage
                 query_length
                 target_coverage
                 target_length
             }
             aligned_regions {
                 query_begin
                 query_end
                 target_begin
                 target_end
                 exon_shift
             }
         }
 
     }
 }

Importing RCSB GraphQL interfaces

data-api/yosemite server

E.g. import {CoreEntry, RcsbEntryContainerIdentifiers} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Yosemite/GqlTypes";

1d-coordinates/borrego server

E.g. import {AnnotationFeatures, Feature, AlignmentResponse} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Types/Borrego/GqlTypes";

GRphQL query validation

import {validateQueries} from "@rcsb/rcsb-api-tools/build/RcsbGraphQL/Generator/GeneratorTools";
validateQueries(graphql_schema_url, "path_to_queries/my_query.graphql");

Requesting RCSB Search data

import {SearchRequest} from "@rcsb/rcsb-api-tools/build/RcsbSearch/SearchRequest";

const client = new SearchRequest();

client.request(query_object);

Example

import {SearchQuery} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchQueryInterface";
import {LogicalOperator, ReturnType, Service, Type} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchEnums";
import {RcsbSearchMetadata} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchMetadata";

const search_query = {
    query: {
        type: Type.Group,
        nodes:[{
            type:Type.Terminal,
            service: Service.FullText,
            parameters:{
                attribute:RcsbSearchMetadata.RcsbEntryInfo.DiffrnResolutionHigh.Value.path,
                operator:RcsbSearchMetadata.RcsbEntryInfo.DiffrnResolutionHigh.Value.operator.Greater,
                value: 2
            }
        },{
            type: Type.Terminal,
            service: Service.FullText,
            parameters: {
                attribute: RcsbSearchMetadata.RcsbEntitySourceOrganism.TaxonomyLineage.Name.path,
                operator: RcsbSearchMetadata.RcsbEntitySourceOrganism.TaxonomyLineage.Name.operator.ExactMatch,
                value: "Homo sapiens"
            }
        }],
        logical_operator: LogicalOperator.And,
    },
    return_type: ReturnType.PolymerEntity
};
const search = new SearchRequest();
search.request(search_query);

Importing RCSB Search classes/interfaces

Search metadata class

Search metadata class provides the searchable paths and methods for the RCSB Search API

import {RcsbSearchMetadata} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchMetadata";

Utility examples

E.g. RcsbSearchMetadata.RcsbEntryInfo.DiffrnResolutionHigh.Value.path attribute contains the string "rcsb_entry_info.diffrn_resolution_high.value"

E.g. RcsbSearchMetadata.RcsbEntryInfo.DiffrnResolutionHigh.Value.operator enumerates the possible comparison operations (i.e. Equals, Greater, Range, ...)

Search enums

Search enums provide a collection of enums/classes that provide a controlled vocabulary to build the RCSB Search queries. The name of each enum/class (camel cased) matches with the RCSB search schema field name in snake case format. E.g. import {AggregationType, Operator, ReturnType, Service} from "@rcsb/rcsb-api-tools/build/RcsbSearch/Types/SearchEnums";

AggregationType encodes the possible values of the schema field "aggregation_type", i.e. AggregationType.Terms = "terms", AggregationType.Histogram = "histogram", ...

Building GraphQL types from specific URLs

  • GraphQL types can be generated from specific URLs. By default, production server are used
    • E.g. npm run buildGraphQLInterfaces -- --data-api http://132.249.210.199/graphql --1d-service http://132.249.213.161/graphql

External schemas

  • DW schemas are collected from rcsb-mojave-model project released in maven.

    • rcsb-mojave-model:target/generated-sources/schema/core
  • Search API schemas are collected from the rcsb-arches git repo.

    • rcsb-arches:src/main/resources/schema
Download external schemas
  • DW schemas

    • npm run downloadDwSchemas -- --schema-version <VERSION-TAG>
    • E.g. npm run downloadDwSchemas -- --schema-version 1.32.1-MODELS-SNAPSHOT
  • Search schemas

    • npm run downloadSearchSchemas -- --branch-name <GIT-REMOTE-BRANCH-NAME>
    • E.g. npm run downloadSearchSchemas -- --branch-name dev-computed-models
4.2.0

1 month ago

4.1.14

3 months ago

4.1.12

10 months ago

4.1.13

10 months ago

4.1.8

12 months ago

4.1.7

12 months ago

4.1.9

12 months ago

4.1.10

12 months ago

4.1.11

12 months ago

4.1.6

12 months ago

4.1.5

12 months ago

4.1.4

1 year ago

4.1.3

1 year ago

4.1.2

1 year ago

4.1.1-beta.1

2 years ago

4.1.1

2 years ago

4.1.0-models.3

2 years ago

4.1.0-models.2

2 years ago

4.1.0

2 years ago

4.0.6

2 years ago

4.1.0-models.1

2 years ago

4.1.0-models

2 years ago

4.0.5

2 years ago

4.0.4

2 years ago

4.0.3

2 years ago

4.0.2

2 years ago

4.0.0-groups.11

2 years ago

4.0.0-groups.12

2 years ago

4.0.1

2 years ago

4.0.0

2 years ago

4.0.0-groups.10

2 years ago

3.0.1-groups.6

2 years ago

3.0.1-groups.5

2 years ago

3.0.1-groups.7

2 years ago

4.0.0-groups.9

2 years ago

3.0.1-groups.4

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0-groups.2

2 years ago

3.0.0-groups.1

2 years ago

2.3.0

2 years ago

2.2.3

2 years ago

2.3.1

2 years ago

2.2.4

2 years ago

2.2.1-groups.11

2 years ago

2.2.1-groups.12

2 years ago

2.2.1-groups.13

2 years ago

2.2.1-groups.14

2 years ago

2.2.1-groups.15

2 years ago

2.2.1-groups.16

2 years ago

2.2.1-groups.17

2 years ago

3.0.0

2 years ago

3.0.0-groups

2 years ago

2.2.2

2 years ago

2.2.1-groups.10

2 years ago

2.2.1-groups.9

3 years ago

2.2.1

3 years ago

2.2.0-groups.9

3 years ago

2.2.0

3 years ago