<commit_before>import json
from pyramid.response import Response
from src.sgd.frontend import config
from urllib2 import Request, urlopen, URLError

patmatch_url = "http://patmatch.dev.yeastgenome.org/"
                
def do_patmatch(request):

    p = dict(request.params)

    if p.get('conf'):
        data = _get_config(p.get('conf'))
        return Response(body=json.dumps(data), content_type='application/json')
        
    data = _run_patmatch(p)

    return Response(body=json.dumps(data), content_type='application/json')

def _run_patmatch(p):

    from urllib2 import Request, urlopen, URLError

    paramData = _construct_patmatch_parameters(p)

    url = patmatch_url + "cgi-bin/aws-patmatch" 

    req = Request(url=url, data=paramData)

    res = urlopen(req)

    result = res.read()

    dataSet = result.split("\t")
    
    if dataSet[1]:
        data = { "result": dataSet[0],
                 "hits":   json.loads(dataSet[1]),
                 "totalHits": dataSet[2],
                 "showHits": dataSet[3]}
    else:
        data = { "result": dataSet[0],
                 "hits": "",
                 "totalHits": 0,
                 "showHits": 0}

    return data

def _construct_patmatch_parameters(p):

    insertion = 1  if p.get('insertion') else 0 
    deletion = 1 if p.get('deletion') else 0
    substitution = 1  if p.get('substitution') else 0
    
    if strand.startswith('Both'):
        strand = 'both'
    elif strand.startswith('Reverse'):<commit_msg>working in progress<commit_after>import json
from pyramid.response import Response
from src.sgd.frontend import config
from urllib2 import Request, urlopen, URLError

patmatch_url = "http://patmatch.dev.yeastgenome.org/"
                
def do_patmatch(request):

    p = dict(request.params)

    if p.get('conf'):
        data = _get_config(p.get('conf'))
        return Response(body=json.dumps(data), content_type='application/json')
        
    data = _run_patmatch(p)

    return Response(body=json.dumps(data), content_type='application/json')

def _run_patmatch(p):

    from urllib2 import Request, urlopen, URLError

    paramData = _construct_patmatch_parameters(p)

    # url = patmatch_url + "cgi-bin/aws-patmatch" 
    # req = Request(url=url, data=paramData)
    url = patmatch_url + "patmatch/patmatch.json"
    req = Request(url=url)
    res = urlopen(req)
    result = res.read()

    url patmatch_url + "patmatch/patmatch.json"

    dataSet = result.split("\t")
    
    if dataSet[1]:
        data = { "result": dataSet[0],
                 "hits":   json.loads(dataSet[1]),
                 "totalHits": dataSet[2],
                 "showHits": dataSet[3]}
    else:
        data = { "result": dataSet[0],
                 "hits": "",
                 "totalHits": 0,
                 "showHits": 0}

    return data

def _construct_patmatch_parameters(p):

    insertion = 1  if p.get('insertion') else 0 
    deletion = 1 if p.get('deletion') else 0
    substitution = 1  if p.get('substitution') else 0
    
    if strand.startswith('Both'):
        strand = 'both'
    elif strand.startswith('Reverse'):
{'fraction_non_alphanumeric': 0.12695874640230254, 'fraction_numerical': 0.010233450591621363, 'mean_word_length': 2.5424688561721402, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1538710', 'n_tokens_mistral': 1072, 'n_tokens_neox': 1001, 'n_words': 217}