Python Client:

Basic Python Program

The simple python template program provides a basic set of functions for querying the G2S API via the Python platform for scientific computing.

#Python 2.7
#A Simple Python template program reading G2S APIs

import requests
from requests.auth import HTTPDigestAuth
import json

#Setup API, e.g. https://g2s.genomenexus.org/swagger-ui.html
#Can change to any valid URL in G2S API

hostName="https://g2s.genomenexus.org/api/"
apiName="alignments"
varType="hgvs-grch37"
varName="17:g.79478130C>G"
apiType="residueMapping"

# Set up API URL
url = hostName+apiName+"/"+varType+"/"+varName+"/"+apiType

# Request API
myResponse = requests.get(url)
#print (myResponse.status_code)

# For successful API call, response code will be 200 (OK)
if(myResponse.ok):
    # Loads (Load String) takes a Json file and converts into python data structure (dict or list, depending on JSON)
        # In this Example, jData are lists of Residues from Genome Mapping to Protein Structures
    jData = json.loads(myResponse.content)
    #pring output
    print(jData)
    print("\n")
else:
  # If response code is not ok (200), print the resulting http error code with description
    myResponse.raise_for_status()
        

Comprehensive Python Client

A comprehensive python client can be generated by swagger-Codegen as follows:

# swagger_client
A Genome to Strucure (G2S) API Supports Automated Mapping and Annotating Genomic Variants in 3D Protein Structures. Supports Inputs from Human Genome Position, Uniprot and Human Ensembl Names

This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:

- API version: 1.0 (beta)
- Package version: 1.0.0
- Build package: io.swagger.codegen.languages.PythonClientCodegen
For more information, please visit [https://g2s.genomenexus.org](https://g2s.genomenexus.org)

## Requirements.

Python 2.7 and 3.4+

## Installation and Usage

git clone https://github.com/swagger-api/swagger-codegen
cd swagger-codegen
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i https://g2s.genomenexus.org/v2/api-docs?group=api \
-l python \
-o {YOURFOLDER/}py_api_client

(if you're on Windows, replace the last command with java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i https://g2s.genomenexus.org/v2/api-docs?group=g2s  -l python
-o {YOURFOLDER\}py_api_client)




### pip install (optional)

If you have not install certifi, you may need to run `pip install certif`
`

### Setuptools

Install via [Setuptools](http://pypi.python.org/pypi/setuptools).

```sh
python setup.py install --user
```
`

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:

```python
from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = swagger_client.GetAlignmentsApi()
id_type = 'ensembl' # str | Input id_type: ensembl; uniprot; uniprot_isoform
id = 'ENSP00000484409.1' # str | Input id e.g. ensembl:ENSP00000484409.1/ENSG00000141510.16/ENST00000504290.5; uniprot:P04637/P53_HUMAN; uniprot_isoform:P04637_9/P53_HUMAN_9
pdb_id = '2fej' # str | Input PDB Id e.g. 2fej
chain_id = 'A' # str | Input Chain e.g. A

try:
    # Get PDB Alignments by ProteinId, PDBId and Chain
    api_response = api_instance.get_alignment_by_pdb_using_get(id_type, id, pdb_id, chain_id)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling GetAlignmentsApi->get_alignment_by_pdb_using_get: %s\n" % e)

```
`

## Documentation for API Endpoints

All URIs are relative to *https://g2s.genomenexus.org*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*GetAlignmentsApi* | [**get_alignment_by_pdb_using_get**](docs/GetAlignmentsApi.md#get_alignment_by_pdb_using_get) | **GET** /api/alignments/{id_type}/{id}/pdb/{pdb_id}_{chain_id} | Get PDB Alignments by ProteinId, PDBId and Chain
*GetAlignmentsApi* | [**get_alignment_using_get**](docs/GetAlignmentsApi.md#get_alignment_using_get) | **GET** /api/alignments/{id_type}/{id} | Get PDB Alignments by ProteinId
*GetAlignmentsApi* | [**get_pdb_alignment_by_sequence_using_get**](docs/GetAlignmentsApi.md#get_pdb_alignment_by_sequence_using_get) | **GET** /api/alignments | Get PDB Alignments by Protein Sequence
*GetAlignmentsApi* | [**get_pdb_alignment_by_sequence_using_post**](docs/GetAlignmentsApi.md#get_pdb_alignment_by_sequence_using_post) | **POST** /api/alignments | Get PDB Alignments by Protein Sequence
*GetResidueMappingApi* | [**get_pdb_alignment_reisude_by_sequence_using_get**](docs/GetResidueMappingApi.md#get_pdb_alignment_reisude_by_sequence_using_get) | **GET** /api/alignments/residueMapping | Get PDB Residue Mapping by Protein Sequence and Residue position
*GetResidueMappingApi* | [**get_pdb_alignment_reisude_by_sequence_using_post**](docs/GetResidueMappingApi.md#get_pdb_alignment_reisude_by_sequence_using_post) | **POST** /api/alignments/residueMapping | Get PDB Residue Mapping by Protein Sequence and Residue position
*GetResidueMappingApi* | [**post_residue_mapping_by_pdb_using_get**](docs/GetResidueMappingApi.md#post_residue_mapping_by_pdb_using_get) | **GET** /api/alignments/{id_type}/{id}/pdb/{pdb_id}_{chain_id}/residueMapping | Post Residue Mapping by ProteinId, PDBId and Chain
*GetResidueMappingApi* | [**post_residue_mapping_by_pdb_using_post**](docs/GetResidueMappingApi.md#post_residue_mapping_by_pdb_using_post) | **POST** /api/alignments/{id_type}/{id}/pdb/{pdb_id}_{chain_id}/residueMapping | Post Residue Mapping by ProteinId, PDBId and Chain
*GetResidueMappingApi* | [**post_residue_mapping_using_get**](docs/GetResidueMappingApi.md#post_residue_mapping_using_get) | **GET** /api/alignments/{id_type}/{id}/residueMapping | POST PDB Residue Mapping by ProteinId
*GetResidueMappingApi* | [**post_residue_mapping_using_post**](docs/GetResidueMappingApi.md#post_residue_mapping_using_post) | **POST** /api/alignments/{id_type}/{id}/residueMapping | POST PDB Residue Mapping by ProteinId


## Documentation For Models

 - [Alignment](docs/Alignment.md)
 - [ResidueMapping](docs/ResidueMapping.md)


## Documentation For Authorization

 All endpoints do not require authorization.


## Author

wangjue@missouri.edu