Exemplo n.º 1
0
 def _get_connection(self, name):
     """ Create a connection object to CubicWeb instance.
     """
     if self.connection is None:
         url = self.conf[name]["url"]
         login, password = ask_credential()
         self.connection = CWInstanceConnection(
             url, login, password, verify=True,
             server_root="/home/{0}".format(login))
     return self.connection
url = "https://metagen.partenaires.cea.fr/metagen"

#############################################################################
# SNP information
# ---------------

# Define the RQL request
rql = ("Any SP, SM, CN, GN Where S is Snp, S rs_id 'rs75684916', "
       "S position SP, S maf SM, S snp_chromosome C, C name CN, "
       "S snp_genes G, G hgnc_name GN")

# Ask for login & password
login, password = ask_credential()

# Define a connection: disable the security certificate check
connection = CWInstanceConnection(url, login, password, verify=False)

# Execute the request
rset = connection.execute(rql)
pprint(rset)
info = {"rs75684916": {}}
for position, maf, chr_name, gene_name in rset:
    info["rs75684916"]["position"] = position
    info["rs75684916"]["maf"] = maf
    info["rs75684916"]["chr_name"] = chr_name
    info["rs75684916"].setdefault("gene_names", {})[gene_name] = {}
print("Information about SNP 'rs75684916': ")
pprint(info)

#############################################################################
# Add Gene information
Exemplo n.º 3
0
#############################################################################
# Get some PLINK data
# -------------------
#
# We want to download the QC Gentic PLINK data available in IMAGEN.
# Define CubicWeb service url
url = "https://imagen2.cea.fr/database"

# Ask for login & password
print(url)
login, password = ask_credential()

# Define a connection
connection = CWInstanceConnection(url,
                                  login,
                                  password,
                                  verify=True,
                                  server_root="/home/{0}".format(login))

# Define the RQL request
rql = "Any G Where G is GenomicMeasure, G label 'QC_Genetics'"

# Create a persistent temporary directory
tmp_dir = os.path.join(os.sep, "tmp", "cwbrowser_data")
if not os.path.isdir(tmp_dir):
    os.mkdir(tmp_dir)

# Execute the request
rset = connection.execute_with_sync(rql, sync_dir=tmp_dir, nb_tries=5)
pprint(rset)
Exemplo n.º 4
0
# Define CubicWeb service url
url = "https://metagen.partenaires.cea.fr/metagen"

#############################################################################
# For one gene
# ------------

# Define the RQL request
rql = "Any I Where X is Gene, X hgnc_name 'BRCA2', X gene_snps S, S rs_id I"

# Ask for login & password
login, password = ask_credential()

# Define a connection: disable the security certificate check
connection = CWInstanceConnection(url, login, password, verify=False)

# Execute the request
rset = connection.execute(rql)
pprint(rset[:10])
print("...")
print("Number of SNPs associated to 'BRCA2': ", len(rset))

#############################################################################
# For a list of genes
# -------------------

# Define the RQL request
rql = ("Any N, I Where X is Gene, X hgnc_name IN ('BRCA2', 'TOMM22P2'), "
       "X hgnc_name N, X gene_snps S, S rs_id I")
Exemplo n.º 5
0
url = "https://imagen2.cea.fr/database"

#############################################################################
# List RAW types
# --------------
#
# We first list all the available RAW data types.

# Define the RQL request
rql = "DISTINCT Any L ORDERBY L Where S is Scan, S label L"

# Ask for login & password
login, password = ask_credential()

# Define a connection
connection = CWInstanceConnection(url, login, password, verify=True,
                                  server_root="/home/{0}".format(login))

# Execute the request
rset = connection.execute(rql)
pprint(rset)


#############################################################################
# Get T1 data
# -----------
#
# We want to list all the available T1 data and associated subjects.

# Define the RQL request
rql = ("Any S, C Where S is Scan, S subject SU, SU code_in_study C, S label "
       "'ADNI_MPRAGE'")
    return snp_data

#############################################################################
# Get some PLINK data
# -------------------
#
# We want to download the QC Gentic PLINK data available in IMAGEN.
# Define CubicWeb service url
url = "https://imagen2.cea.fr/database"

# Ask for login & password
print(url)
login, password = ask_credential()

# Define a connection
connection = CWInstanceConnection(url, login, password, verify=True,
                                  server_root="/home/{0}".format(login))

# Define the RQL request
rql = "Any G Where G is GenomicMeasure, G label 'QC_Genetics'"

# Create a persistent temporary directory
tmp_dir = os.path.join(os.sep, "tmp", "cwbrowser_data")
if not os.path.isdir(tmp_dir):
    os.mkdir(tmp_dir)

# Execute the request
rset = connection.execute_with_sync(rql, sync_dir=tmp_dir, nb_tries=5)
pprint(rset)

# Unzip the downloaded file
zip_file = rset[0][0]
Exemplo n.º 7
0
#############################################################################
# List questionnaires
# -------------------
#
# We first list all the available questionnaires.

# Define the RQL request
rql = "DISTINCT Any QN ORDERBY QN Where Q is Questionnaire, Q name QN"

# Ask for login & password
login, password = ask_credential()

# Define a connection
connection = CWInstanceConnection(url,
                                  login,
                                  password,
                                  verify=True,
                                  server_root="/home/{0}".format(login))

# Execute the request
rset = connection.execute(rql)
pprint(rset)

#############################################################################
# Get the 'PSYTOOLS-adsr-youth' questionnaire
# -------------------------------------------
#
# We want to get all the available 'PSYTOOLS-adsr-youth' questionnaire data.
# We ask the system for all the subjects and all the timepoints.

# Define the RQL request