def response(returndata):

    credInfo = DQXDbTools.CredentialInformation(returndata)
    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])
    baseFolder = config.SOURCEDATADIR + '/datasets'
    settingsFile = os.path.join(baseFolder, databaseName, 'refgenome', 'settings')

    try:
        if not os.path.exists(settingsFile):
            returndata['content'] = DQXbase64.b64encode_var2('AnnotMaxViewPortSize: 750000  # Maximum viewport (in bp) the genome browser can have in order to show the annotation track\nRefSequenceSumm: No          # Include a summary track displaying the reference sequence\n')
        else:
            with open(settingsFile, 'r') as fp:
                content = fp.read()
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
Beispiel #2
0
def response(returndata):
    filename=returndata['name']
    #!!!todo: add more integrity checks for the filename
    if filename.find('..')>=0:
        raise Exception('Invalid file name')
    f=open(config.BASEDIR+'/'+filename+'.txt')
    content=f.read()
    f.close()
    returndata['content']=DQXbase64.b64encode_var2(content)
    return returndata
def response(returndata):

    credInfo = DQXDbTools.CredentialInformation(returndata)
    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])
    baseFolder = config.SOURCEDATADIR + '/datasets'
    settingsFile = os.path.join(baseFolder, databaseName, 'refgenome', 'chromosomes')

    try:
        if not os.path.exists(settingsFile):
            returndata['content'] = DQXbase64.b64encode_var2('chrom	length\nChrom_01\t1.54\nChrom_02\t0.85\n')
        else:
            with open(settingsFile, 'r') as fp:
                content = fp.read()
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
def response(returndata):

    credInfo = DQXDbTools.ParseCredentialInfo(returndata)

    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])

    baseFolder = config.SOURCEDATADIR + '/datasets'
    settingsFile = os.path.join(baseFolder, databaseName, 'refgenome',
                                'chromosomes')

    try:
        if not os.path.exists(settingsFile):
            returndata['content'] = DQXbase64.b64encode_var2(
                'chrom	length\nChrom_01\t1.54\nChrom_02\t0.85\n')
        else:
            with open(settingsFile, 'r') as fp:
                content = fp.read()
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
def response(returndata):

    credInfo = DQXDbTools.ParseCredentialInfo(returndata)

    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])

    baseFolder = config.SOURCEDATADIR + '/datasets'
    settingsFile = os.path.join(baseFolder, databaseName, 'refgenome',
                                'settings')

    try:
        if not os.path.exists(settingsFile):
            returndata['content'] = DQXbase64.b64encode_var2(
                'AnnotMaxViewPortSize: 750000  # Maximum viewport (in bp) the genome browser can have in order to show the annotation track\nRefSequenceSumm: No          # Include a summary track displaying the reference sequence\n'
            )
        else:
            with open(settingsFile, 'r') as fp:
                content = fp.read()
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
Beispiel #6
0
def response(returndata):

    credInfo = DQXDbTools.ParseCredentialInfo(returndata)

    sourcetype = DQXDbTools.ToSafeIdentifier(returndata['sourcetype'])
    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])
    workspaceid = DQXDbTools.ToSafeIdentifier(returndata['workspaceid'])
    tableid = DQXDbTools.ToSafeIdentifier(returndata['tableid'])
    sourceid = DQXDbTools.ToSafeIdentifier(returndata['sourceid'])

    credInfo.VerifyCanDo(
        DQXDbTools.DbOperationWrite(databaseName, 'workspaces'))

    baseFolder = config.SOURCEDATADIR + '/datasets'

    dataFile = None
    if sourcetype == 'datatable':
        dataFile = os.path.join(baseFolder, databaseName, 'datatables',
                                tableid, 'data')
    if sourcetype == 'customdata':
        dataFile = os.path.join(baseFolder, databaseName, 'workspaces',
                                workspaceid, 'customdata', tableid, sourceid,
                                'data')
    if dataFile is None:
        returndata['Error'] = 'Invalid file source type'
        return returndata

    try:
        if not os.path.exists(dataFile):
            returndata['content'] = ''
        else:
            with open(dataFile, 'r') as fp:
                content = ''
                linecount = 0
                for line in fp:
                    content += line
                    if linecount > 100:
                        break
                    linecount += 1
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
def response(returndata):

    credInfo = DQXDbTools.CredentialInformation(returndata)

    sourcetype = DQXDbTools.ToSafeIdentifier(returndata['sourcetype'])
    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])
    workspaceid = DQXDbTools.ToSafeIdentifier(returndata['workspaceid'])
    tableid = DQXDbTools.ToSafeIdentifier(returndata['tableid'])
    sourceid = DQXDbTools.ToSafeIdentifier(returndata['sourceid'])

    credInfo.VerifyCanDo(DQXDbTools.DbOperationWrite(databaseName, 'workspaces'))


    baseFolder = config.SOURCEDATADIR + '/datasets'

    settingsFile = None
    if sourcetype == 'dataset':
        settingsFile = os.path.join(baseFolder, databaseName, 'settings')
    if sourcetype == 'datatable':
        settingsFile = os.path.join(baseFolder, databaseName, 'datatables', tableid, 'settings')
    if sourcetype == '2D_datatable':
        settingsFile = os.path.join(baseFolder, databaseName, '2D_datatables', tableid, 'settings')
    if sourcetype == 'customdata':
        settingsFile = os.path.join(baseFolder, databaseName, 'workspaces', workspaceid, 'customdata', tableid, sourceid, 'settings')
    if sourcetype == 'workspace':
        settingsFile = os.path.join(baseFolder, databaseName, 'workspaces', workspaceid, 'settings')
    if settingsFile is None:
        returndata['Error'] = 'Invalid file source type'
        return returndata

    try:
        if not os.path.exists(settingsFile):
            returndata['content'] = ''
        else:
            with open(settingsFile, 'r') as fp:
                content = fp.read()
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
def response(returndata):

    credInfo = DQXDbTools.ParseCredentialInfo(returndata)

    sourcetype = DQXDbTools.ToSafeIdentifier(returndata['sourcetype'])
    databaseName = DQXDbTools.ToSafeIdentifier(returndata['database'])
    workspaceid = DQXDbTools.ToSafeIdentifier(returndata['workspaceid'])
    tableid = DQXDbTools.ToSafeIdentifier(returndata['tableid'])
    sourceid = DQXDbTools.ToSafeIdentifier(returndata['sourceid'])

    credInfo.VerifyCanDo(DQXDbTools.DbOperationWrite(databaseName, 'workspaces'))

    baseFolder = config.SOURCEDATADIR + '/datasets'

    dataFile = None
    if sourcetype == 'datatable':
        dataFile = os.path.join(baseFolder, databaseName, 'datatables', tableid, 'data')
    if sourcetype == 'customdata':
        dataFile = os.path.join(baseFolder, databaseName, 'workspaces', workspaceid, 'customdata', tableid, sourceid, 'data')
    if dataFile is None:
        returndata['Error'] = 'Invalid file source type'
        return returndata

    try:
        if not os.path.exists(dataFile):
            returndata['content'] = ''
        else:
            with open(dataFile, 'r') as fp:
                content = ''
                linecount = 0
                for line in fp:
                    content += line
                    if linecount > 100:
                        break
                    linecount += 1
                returndata['content'] = DQXbase64.b64encode_var2(content)

    except Exception as e:
        returndata['Error'] = str(e)

    return returndata
Beispiel #9
0
def response(returndata):
    url = returndata['url']
    
    cache = getCache()
    cacheKey = json.dumps([url])
    returndata['content'] = None
    use_cache = returndata['cache'] and not os.getenv('STAGING', '')
    if use_cache:
        try:
            returndata['content'] = cache[cacheKey]
        except KeyError:
            pass
    
    if returndata['content'] is None:
        file = urllib.request.urlopen(url)
        data = file.read()
        file.close()
        data = xmltodict.parse(data)
        returndata['content'] = DQXbase64.b64encode_var2(json.dumps(data))
        if use_cache:
            cache[cacheKey] = returndata['content']
    
    return returndata
Beispiel #10
0
def response(returndata):
    url = returndata['url']

    cache = getCache()
    cacheKey = json.dumps([url])
    returndata['content'] = None
    use_cache = returndata['cache'] and not os.getenv('STAGING', '')
    if use_cache:
        try:
            returndata['content'] = cache[cacheKey]
        except KeyError:
            pass

    if returndata['content'] is None:
        file = urllib.request.urlopen(url)
        data = file.read()
        file.close()
        data = xmltodict.parse(data)
        returndata['content'] = DQXbase64.b64encode_var2(json.dumps(data))
        if use_cache:
            cache[cacheKey] = returndata['content']

    return returndata