AnnoLnc provides 3 JSON-based web service APIs for programmatically uploading sequences and fetch bulk results. You can use the APIs by any language that can handle HTTP request and response.

# Name URL Parameters Return HTTP Method
1 Upload http://annolnc.cbi.pku.edu.cn/service/upload

file: a file containing lncRNA sequences (less than 500) in fasta format. For more upload requirement, please see here.

email: your email address used to apply the token. Please see Apply for token.

token: you can find the token in your email box after applying.

The job ID. POST
2 Info http://annolnc.cbi.pku.edu.cn/service/info id: the job ID. The run info of this job, especially the run status for each sequence. Note that you can only get the download URL after all analyses are finished. Please check the run status first before fetching the download URL. GET, POST
3 Fetch http://annolnc.cbi.pku.edu.cn/service/fetch

submitID: the job ID.

[seqName]: the name of a lncRNA which you want to download its annotation results.

The URL of the annotation results in a ZIP package. GET, POST

To avoid the server to be overloaded, now users are required to apply tokens to use the "Upload" service. Each user can have at most two jobs running at the same time. Please enter your email in the box and click "Apply". The token will be sent to your email address. If you would like to cancel running jobs, please contact annolnc@mail.cbi.pku.edu.cn.

Our APIs are very easy to be integrated into your scripts. Following are simple demos in Python 2.7.


# Note: these demos require the package "requests"

>>> import requests
>>> import json

############### UPLOAD FASTA FILE ###############

# Prepare parameters
# upload.fa is the fasta file containing lncRNA sequences
>>> upload_file = {'file': open('upload.fa', 'rb')}

# your email used to apply the token
>>> email = 'username@example.com'
>>> token = 'your_token_received_in_email'
>>> params = {'email': email, 'token': token}

# Use the upload API to upload file and get the response in json
>>> r1 = requests.post('http://annolnc.cbi.pku.edu.cn/service/upload', files = upload_file, params = params).json()

# a function to print json
def print_json(j):
    print json.dumps(j, indent = 4)

# If the file is uploaded sucessfully, you can get the job_id, ohterwise you'll see error messages. 
# If there are some sequences that are discarded, you'll see their names in "invalid_seqs". 
>>> print_json(r1)
{
    "status": "success", 
    "invalid_seqs": "", 
    "error_msgs": "", 
    "job_id": "C0545D80-150330163518"
}

#################### GET INFO ####################
>>> job_id = r1['job_id']

# Prepare parameters
>>> param = {'id': job_id}

# Use the info API to get info of this job
>>> r2 = requests.post('http://annolnc.cbi.pku.edu.cn/service/info', data = param).json()

# Note: we recommand you check the run_status before fetching download URLs. You can only get the download URL when the "run_status" is "finished".
>>> print_json(r2)
{
    "run_status": "finished", 
    "total_seq": 2, 
    "detail": [
        {
            "seq_name": "linc00951_hg_1", 
            "run_status": "finished", 
            "length": 3122, 
            "location": "chr6:40312084-40323745(-)", 
            "trans_id": "14062"
        }, 
        {
            "seq_name": "tusc7_hg_1", 
            "run_status": "finished", 
            "length": 2105, 
            "location": "chr3:116428635-116435887(+)", 
            "trans_id": "2054"
        }
    ], 
    "job_id": "C0545D80-150330163518", 
    "error_msgs": ""
}

#################### FETCH ANNOTATION DOWNLOAD URL ####################
# Prepare parameters
>>> param = {'submitID': job_id}

# Use the fetch API to get the URL to download the annotation results of the job
>>> r3 = requests.post('http://annolnc.cbi.pku.edu.cn/service/fetch', data = param).json()
>>> print_json(r3)
{
    "URL": [
        "http://annolnc.cbi.pku.edu.cn/submit/C0/C0545D80-150330163518/C0545D80-150330163518.zip"
    ], 
    "seq_name": "", 
    "error_msgs": "", 
    "job_id": "C0545D80-150330163518"
}

# You can also fetch resuls for a specific sequence
>>> seq_name = 'tusc7_hg_1'
>>> param = {'submitID': job_id, 'seqName': seq_name}
>>> r4 = requests.post('http://annolnc.cbi.pku.edu.cn/service/fetch', data = param).json()
>>> print_json(r4)
{
    "URL": [
        "http://annolnc.cbi.pku.edu.cn/submit/C0/C0545D80-150330163518/tusc7_hg_1_2054.zip"
    ], 
    "seq_name": "tusc7_hg_1", 
    "error_msgs": "", 
    "job_id": "C0545D80-150330163518"
}