예제 #1
0
def get_feature_data(ref_seq):
    """
    :param ref_seq(chromosome): the query string in the format of (refseq_name)?start=234&end=5678
    :return: json of the features
    JBrowse Track should look like:
    {
    "label":      "my_rest_track",
    "key":        "REST Test Track",
    "type":       "JBrowse/View/Track/HTMLFeatures",
    "storeClass": "JBrowse/Store/SeqFeature/REST",
    "baseUrl":    "http://ip_address/JBrowse",
    "query": {
        "type": "vcf"  || "transcript"
        "experiment_id": "experiment-id1_experiment-id2" (experiment_id should relate to sample in vcf)
            }
    }

curl -i http://127.0.0.1:5000/JBrowse/features/chr7?start=123615\&end=208824\&type=vcf\&experiment_id=10_8&vcf_file=
curl -i http://127.0.0.1:5000//jsrv/JBrowse/features/chr1?type=vcf\&experiment_id=70_71\&vcf_file=%2Fdata%2Fscratch%2Fs3_data%2Fpatient-data-results.ctig.com%2FRebiopBarRB3%2FDNA_BWA_CTIG_2013_6_17%2FSTRELKA__VID__115__EIDS__70__72__BIDS__415__419__BCODES__Rebiop-Normal-DNA_ExomeAgilentV5TruSeq-6-19-25-22-70-__Rebiop-TumorPostTx-DNA_ExomeAgilentV5TruSeq-6-20-26-23-72-__all.somatic.indels.dbsnp.snpeff.annotated.gwas.vcf.gz\&start=137499999\&end=149999999


    """
    res = {}
    res['features'] = []
    chr = ref_seq
    start= request.args.get('start')
    end = request.args.get('end')
    type = request.args.get('type')
    cur = conn.cursor()
    if type == 'vcf':
        vcf_file = urllib.unquote_plus(request.args.get('vcf_file'))

        experiment_ids = request.args.get('experiment_id').split('_')


 #       results = query_psql(chr, start, end, experiment_ids, cur)
        results = query_multicorn(vcf_file, chr, start, end, cur)
        print results
        #return json.dumps({'res': len(results)})
        return vcf_json(results, cur)
__author__ = 'urvishparikh'
from jbrowse_json_builder import vcf_json
from collections import namedtuple
import psycopg2

vcf_line = namedtuple('vcf_line', ['contig', 'pos', 'ref', 'alt', 'info', 'filter', 'rsid', 'experiment_id', 'ref_cnt', 'alt_cnt'])


conn = psycopg2.connect("dbname=ctig user=urvish")
cur = conn.cursor()
# print vcf_json([vcf_line(contig='(7,1)', pos=123617, ref='A', alt='T', info='NT=ref;QSS=1;QSS_NT=0;SGT=AT->AT;SOMATIC;TQSS=1;TQSS_NT=1', filter='QSS_ref', rsid='', experiment_id=10, ref_cnt=6, alt_cnt=0),
#           vcf_line(contig='(7,1)', pos=123617, ref='A', alt='T', info='NT=ref;QSS=1;QSS_NT=0;SGT=AT->AT;SOMATIC;TQSS=1;TQSS_NT=1', filter='QSS_ref', rsid='', experiment_id=8, ref_cnt=0, alt_cnt=2),
#           vcf_line(contig='(7,1)', pos=208819, ref='C', alt='A', info='NT=ref;QSS=1;QSS_NT=1;SGT=AC->AC;SOMATIC;TQSS=1;TQSS_NT=1', filter='QSS_ref', rsid='', experiment_id=10, ref_cnt=120, alt_cnt=0),
#           vcf_line(contig='(7,1)', pos=208819, ref='C', alt='A', info='NT=ref;QSS=1;QSS_NT=1;SGT=AC->AC;SOMATIC;TQSS=1;TQSS_NT=1', filter='QSS_ref', rsid='', experiment_id=8, ref_cnt=190, alt_cnt=7)],
#          cur)

print vcf_json([vcf_line(contig='(1,1)', pos=93586207, ref='G', alt='A',
                         info='NT=ref;QSS=25;QSS_NT=25;SGT=GG->AG;SOMATIC;TQSS=2;TQSS_NT=2;EFF=STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W198*|491|MTF2||CODING|NM_001164391.1|10|1),STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W198*|491|MTF2||CODING|NM_001164393.1|7|1),STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W300*|536|MTF2||CODING|NM_001164392.1|9|1),STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W300*|593|MTF2||CODING|NM_007358.3|9|1)',
                         filter='PASS', rsid='', experiment_id=10, ref_cnt=77, alt_cnt=0), vcf_line(contig='(1,1)',
                                                                                                    pos=93586207,
                                                                                                    ref='G', alt='A',
                                                                                                    info='NT=ref;QSS=25;QSS_NT=25;SGT=GG->AG;SOMATIC;TQSS=2;TQSS_NT=2;EFF=STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W198*|491|MTF2||CODING|NM_001164391.1|10|1),STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W198*|491|MTF2||CODING|NM_001164393.1|7|1),STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W300*|536|MTF2||CODING|NM_001164392.1|9|1),STOP_GAINED(HIGH|NONSENSE|tGg/tAg|W300*|593|MTF2||CODING|NM_007358.3|9|1)',
                                                                                                    filter='PASS', rsid='',
                                                                                                    experiment_id=8, ref_cnt=207,
                                                                                                    alt_cnt=6)], cur)