3dsnp v1.0 API

3dsnp for developers

3DSNP provides a more powerful way for users to access the data through the use of API. SNP data can be accessed by two means: SNP ids or Chromatin position.

Overview

URL

http://cbportal.org/3dsnp/api.do

Format supported

JSON/XML

HTTP request method

GET/POST

Login required

No

Data access restrictions

Frequency limit: No

Request

Request parameters

Required Type Information
id/position true string Represents the SNP ID or genomic position, at least one of them is required,
multiple SNP IDs or positions should separated by comma ‘,’.
Dash symbol ‘-‘
The format of parameter ‘position’
should be ‘1000000-1000100’.
chrom false string Represents the chromosome of queried position and is required when parameter ‘position’ is used.
When there are more than one positions, the corresponding chromosomes should also be separated by ‘,’.
type true string Data type for searching, multiple types should be separated by comma ‘,’.
Available types are listed below.
format true string Represents data types returns. Json and XML formats are supported.

Request data type

DataType Description
basic Basic information of SNP, including sequential facts and phenotype from 1000G project.
chromhmm Chromatin state information generated by the core 15-state ChromHMM models trained
across a variety of cell types.
motif Transcription factor binding motifs altered by SNP.
tfbs Transcription factor binding sites in a variety of cell types.
eqtl Expression quantitative trait loci (eQTL).
3dgene Genes that interact the query SNP through chromatin loops.
3dsnp SNPs that interact the query SNP through chromatin loops. Not available for the query of position.
phylop PhyloP scores of genomic region surrounding the query SNP.

Response

Response parameters

Type DataType Description
id string basic SNP ID
chr string basic Chromosome name
position string basic Location of the query
MAF string basic Minor allele frequency
Ref string basic Reference Allele
Alt string basic Alternative Allele
EAS string basic Allele frequency in the EAS populations
AMR string basic Allele frequency in the AMR populations
AFR string basic Allele frequency in the AFR populations
EUR string basic Allele frequency in the EUR populations
SAS string basic Allele frequency in the SAS populations
linearClosestGene string basic Linear cloest genes
data_gene JsonArray basic listed below in JsonArray Parameters
chromhmm string chromhmm Chromatin state from ChromHMM core 15-state model
data_chromhmm JsonArray chromhmm listed below in JsonArray Parameters
motif string motif Sequence motif altered by the query SNP
data_motif JsonArray motif listed below in JsonArray Parameters
tfbs string tfbs Transcription factor binding sites the query locates
data_tfbs JsonArray tfbs listed below in JsonArray Parameters
eqtl string eqtl Expression quantitative trait loci
data_eqtl JsonArray eqtl listed below in JsonArray Parameters
data_loop_gene JsonArray 3dgene listed below in JsonArray Parameters
data_loop_snp JsonArray 3dsnp listed below in JsonArray Parameters
physcores string physcores PhyloP scores of the query SNP and its +/-10 bp adjacent regions

JsonArray Parameters

Type JsonArray Description
geneID string data_gene RefSeq Gene ID
geneName string data_gene Official gene symbol
geneRelativePosition string data_gene Relative position of the closest gene to the query
geneDescription string data_gene Gene description
chromhmmCell string data_chromhmm Cell type of the corresponding chromatin state
chromhmmName string data_chromhmm Short name of chromatin state
chromhmmFullName string data_chromhmm Full name of chromatin state
chromhmmCellDescription string data_chromhmm Cell type description
chromhmmTissue string data_chromhmm Tissue of the cell type
motif string data_motif Motif ID in TRANSFAC or JASPAR
motifStrand string data_motif Strand of the motif
motifSource string data_motif Database source of the motif
motifMatchedSequence string data_motif Matched sequence for the motif
motifMatchedSequencePos string data_motif Relative position of the query to the sequence
motifRef string data_motif Reference allele
motifAlt string data_motif Alternative allel
tfbsCell string data_tfbs Cell type of the corresponding TFBS
tfbsFactor string data_tfbs Name of the transcription factor
tfbsCellTissue string data_tfbs Tissue of the cell type
tfbsDNAAccessibility string data_tfbs DNA accessibility of the TFBS
tfbsCellDescription string data_tfbs Description for the cell type
eqtlGene string data_eqtl Related gene of the eQTL
eqtlPValue string data_eqtl P-value of the eQTL
eqtlTissue string data_eqtl Tissue in which the eQTL identified
eqtlEffect string data_eqtl Effect size of the eQTL
loopGene string data_loop_gene Genes interacting the query SNP through chromatin loops
loopGeneID string data_loop_gene RefSeq Gene ID
loopGeneDescription string data_loop_gene Gene description
loopCell string data_loop_gene/data_loop_snp Cell type in which the chromatin loop was identified
loopCellTissue string data_loop_gene/data_loop_snp Tissue of the cell type
loopCellDescription string data_loop_gene/data_loop_snp Cell type description
loopStart string data_loop_gene/data_loop_snp Start genomic position of the chromatin loop
loopEnd string data_loop_gene/data_loop_snp End genomic position of the chromatin loop
loopType string data_loop_gene/data_loop_snp Type of the chromatin loop: “Within Loop” or “Anchor-to-Anchor”
loopSNP string data_loop_snp SNPs interacting with the query and in the same LD block through chromatin loops
loopLD string data_loop_snp r^2 in LD
loopPopulation string data_loop_snp Continental population (AFR, AMR, ASN, EUR and SAS)

Request with id

URL example1 : single snp and single data type in json format

Request URL :

http://3dsnp.cbportal.org/api.do?id=rs1000&format=json&type=basic

Response format :

[{
"id":"rs1000",
"position":"32153894",
"chrom":"chr6",
"AFR":"",
"AMR":"",
"Alt":"",
"EAS":"",
"EUR":"",
"Ref":"",
"SAS":"",
"MAF":"",
"linearClosestGene":"AGER,177,upstream-variant-2KB;PBX2,5089,utr-variant-3-prime",
"data_gene": [
    {
    "geneID":"177",
    "geneName":"AGER",
    "geneRelativePosition":"upstream-variant-2KB",
    "geneDescription":"advanced glycosylation end product-specific receptor"
    },
    {
    "geneID":"5089",
    "geneName":"PBX2",
    "geneRelativePosition":"utr-variant-3-prime",
    "geneDescription":"pre-B-cell leukemia homeobox 2"
    }
]}]

URL example2 : mutilple snps and mutilple data types in xml format

Request URL :

http://3dsnp.cbportal.org/api.do?id=rs1000,rs10&format=xml&type=basic,eqtl,motif

Response format :

<?xml version="1.0" encoding="utf-8"?>
<a>
<e class="object">
<AFR type="string" />
<AMR type="string" />
<Alt type="string" />
<EAS type="string" />
<EUR type="string" />
<MAF type="string" />
<Ref type="string" />
<SAS type="string" />
<chrom type="string">chr6</chrom>
<data_gene class="array">
<e class="object">
<geneDescription type="string">advanced glycosylation end product-specific receptor</geneDescription>
<geneID type="string">177</geneID>
<geneName type="string">AGER</geneName>
<geneRelativePosition type="string">upstream-variant-2KB</geneRelativePosition>
</e>
<e class="object">
<geneDescription type="string">pre-B-cell leukemia homeobox 2</geneDescription>
<geneID type="string">5089</geneID>
<geneName type="string">PBX2</geneName>
<geneRelativePosition type="string">utr-variant-3-prime</geneRelativePosition>
</e>
</data_gene>
<eqtl type="string" />
<id type="string">rs1000</id>
<linearClosestGene type="string">AGER,177,upstream-variant-2KB;PBX2,5089,utr-variant-3-prime</linearClosestGene>
<motif type="string" />
<position type="number">32153894</position>
</e>
<e class="object">
<AFR type="string">0.997</AFR>
<AMR type="string">0.9524</AMR>
<Alt type="string">C</Alt>
<EAS type="string">1</EAS>
<EUR type="string">0.9453</EUR>
<MAF type="string">A,0.019369</MAF>
<Ref type="string">A</Ref>
<SAS type="string">0.9949</SAS>
<chrom type="string">chr7</chrom>
<data_gene class="array">
<e class="object">
<geneDescription type="string">cyclin-dependent kinase 6</geneDescription>
<geneID type="string">1021</geneID>
<geneName type="string">CDK6</geneName>
<geneRelativePosition type="string">intron-variant</geneRelativePosition>
</e>
</data_gene>
<eqtl type="string" />
<id type="string">rs10</id>
<linearClosestGene type="string">CDK6,1021,intron-variant</linearClosestGene>
<motif type="string" />
<position type="number">92383887</position>
</e>
</a>

Request with position

URL example3 : single position and single data type in json format

Request URL :

http://3dsnp.cbportal.org/api.do?position=1000000-1100000&chrom=chr11&format=json&type=basic

Response format :

[{
"id":"rs544411125",
"position":"1000017",
"chrom":"chr11",
"AFR":"0",
"AMR":"0",
"Alt":"A",
"EAS":"0",
"EUR":"0",
"Ref":"G",
"SAS":"0.001",
"MAF":"A,0.000199681",
"linearClosestGene":"AP2A2,161,intron-variant",
"data_gene":[
    {
    "geneID":"161",
    "geneName":"AP2A2",
    "geneRelativePosition":"intron-variant",
    "geneDescription":"adaptor related protein complex 2 alpha 2 subunit"
    }]
},
{
"id":"rs561110574",
"position":"1000027",
"chrom":"chr11",
"AFR":"0.0015",
"AMR":"0",
"Alt":"T",
"EAS":"0",
"EUR":"0",
"Ref":"G",
"SAS":"0",
"MAF":"T,0.000399361",
"linearClosestGene":"AP2A2,161,intron-variant",
"data_gene":[
    {
    "geneID":"161",
    "geneName":"AP2A2",
    "geneRelativePosition":"intron-variant",
    "geneDescription":"adaptor related protein complex 2 alpha 2 subunit"
    }]}
]

URL example4 : single position and mutilple data types in xml format

Request URL :

http://3dsnp.cbportal.org/api.do?position=100000-1000100&chrom=chr1&format=xml&type=eqtl,motif

Response format :

<?xml version="1.0" encoding="utf-8"?>
<a>
<e class="object">
<chrom type="string">chr1</chrom>
<data_motif class="array">
<e class="object">
<motif type="string">HEN1_02</motif>
<motifAlt type="string">G</motifAlt>
<motifMatchedSequence type="string">CAGGAAAGCAGCTGGGGGTCCA</motifMatchedSequence>
<motifMatchedSequencePos type="string">21</motifMatchedSequencePos>
<motifRef type="string">A</motifRef>
<motifSource type="string">Transfac</motifSource>
<motifStrand type="string">+</motifStrand>
</e>
</data_motif>
<eqtl type="string" />
<id type="string">rs537152617</id>
<motif type="string">Transfac,HEN1_02,+,CAGGAAAGCAGCTGGGGGTCCA,21</motif>
<position type="number">1000036</position>
</e>
<e class="object">
<chrom type="string">chr1</chrom>
<data_motif class="array">
<e class="object">
<motif type="string">MUSCLE_INI_B</motif>
<motifAlt type="string">T</motifAlt>
<motifMatchedSequence type="string">TCCCGTGGCCATTCAGGCGCC</motifMatchedSequence>
<motifMatchedSequencePos type="string">4</motifMatchedSequencePos>
<motifRef type="string">C</motifRef>
<motifSource type="string">Transfac</motifSource>
<motifStrand type="string">-</motifStrand>
</e>
<e class="object">
<motif type="string">MINI19_B</motif>
<motifAlt type="string">T</motifAlt>
<motifMatchedSequence type="string">TCCCGTGGCCATTCAGGCGCC</motifMatchedSequence>
<motifMatchedSequencePos type="string">4</motifMatchedSequencePos>
<motifRef type="string">C</motifRef>
<motifSource type="string">Transfac</motifSource>
<motifStrand type="string">-</motifStrand>
</e>
<e class="object">
<motif type="string">MINI20_B</motif>
<motifAlt type="string">T</motifAlt>
<motifMatchedSequence type="string">TCCCGTGGCCATTCAGGCGCC</motifMatchedSequence>
<motifMatchedSequencePos type="string">4</motifMatchedSequencePos>
<motifRef type="string">C</motifRef>
<motifSource type="string">Transfac</motifSource>
<motifStrand type="string">-</motifStrand>
</e>
</data_motif>
<eqtl type="string" />
<id type="string">rs573794673</id>
<motif type="string">Transfac,MUSCLE_INI_B,-,TCCCGTGGCCATTCAGGCGCC,4;Transfac,MINI19_B,-,TCCCGTGGCCATTCAGGCGCC,4;Transfac,MINI20_B,-,TCCCGTGGCCATTCAGGCGCC,4</motif>
<position type="number">1000090</position>
</e>
<e class="object">
<chrom type="string">chr11</chrom>
<eqtl type="string" />
<id type="string">rs544411125</id>
<motif type="string" />
<position type="number">1000017</position>
</e>
<e class="object">
<chrom type="string">chr11</chrom>
<eqtl type="string" />
<id type="string">rs561110574</id>
<motif type="string" />
<position type="number">1000027</position>
</e>
</a>

Sample code for java developers

JSON-lib is required for the example, a java library for transforming beans, maps, collections, java arrays and XML to JSON and back again to beans and DynaBeans. You could download it in https://sourceforge.net/projects/json-lib/

public static void main(String[] args) {

    String res_str = MyHttpRequest.sendPost("http://cbportal.org/3dsnp/api.do", "id=rs900012&format=json&type=basic,eqtl,motif");
    JSONArray res_array = JSONArray.fromObject(res_str);
    
    StringBuilder builder = new StringBuilder();
    
    for (int index_snp = 0; index_snp < res_array.size();index_snp++){
    
    JSONObject res_obj = res_array.getJSONObject(index_snp);
    builder.append("id : "+ res_obj.getString("id")+" , chrom : " +res_obj.getString("chrom") + " , num_eqtl : "+res_obj.getJSONArray("data_eqtl").size()+" , num_motif : " + res_obj.getJSONArray("data_motif").size()+"\n");
    }
    
    System.out.println(builder.toString());
}

MyHttpRequest.class is used to send HTTP request.

public class MyHttpRequest {

public static String sendGet(String url, String param) {
    String result = "";
    BufferedReader in = null;
    try {
        String urlNameString = url + "?" + param;
        URL realUrl = new URL(urlNameString);
        
        URLConnection connection = realUrl.openConnection();
        
        connection.setRequestProperty("accept", "*/*");
        connection.setRequestProperty("connection", "Keep-Alive");
        connection.setRequestProperty("user-agent",
        "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
        
        connection.connect();
        
        Map<String, List<String>> map = connection.getHeaderFields();
        
        for (String key : map.keySet()) {
            System.out.println(key + "--->" + map.get(key));
        }

        in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
        String line;
        while ((line = in.readLine()) != null) {
            result += line;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            if (in != null) {
                in.close();
            }
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
    return result;
}

public static String sendPost(String url, String param) {
    PrintWriter out = null;
    BufferedReader in = null;
    String result = "";
    try {
        URL realUrl = new URL(url);
        URLConnection conn = realUrl.openConnection();
        
        conn.setRequestProperty("accept", "*/*");
        conn.setRequestProperty("connection", "Keep-Alive");
        conn.setRequestProperty("user-agent",
        "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
        
        conn.setDoOutput(true);
        conn.setDoInput(true);
        
        out = new PrintWriter(conn.getOutputStream());
        out.print(param);
        out.flush();
        
        in = new BufferedReader(
        new InputStreamReader(conn.getInputStream(),"UTF-8"));
        String line;
        while ((line = in.readLine()) != null) {
            result += line;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try{
            if(out!=null){
                out.close();
            }
            if(in!=null){
                in.close();
            }
        } catch(IOException ex){
            ex.printStackTrace();
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *