Esempio n. 1
0
 def gameover(self):
     self.objects = []
     content = open('gameover','r').read()
     pos = get_list(content)
     gameover_obj = go.Object('gameover')
     gameover_obj.add_pixel([go.pixel(i) for i in pos])
     self.add_object(gameover_obj)
     self.fill_panel()
     self.render_once()
     self.set_pause()
     return 0
Esempio n. 2
0
	def run(self):
		self.complete=0

		if self.play_list:
			try:
				with open('%s'% self.play_list,'r') as v_list:
					tasks=v_list.read().split('\n')
				self.download_list(tasks)
			except Exception as e:
				print('Can\'t find list! check your play_list\'s path!',e)

		else:
			v_url=input('Please input video or playlist url:')
			if 'list=' in v_url:	
				try:
					self.download_list(get_list(v_url))
				except Exception:
					print('Check your playlist url or api-key!')
			else:
				self.req_api(v_url)
Esempio n. 3
0
    def get_command(self,s):
        args = s.split(' ')

        if len(args) == 2:
            if args[0] == ":w":
                tempfile = open(args[1].strip(),'w')
                tempfile.write(self.data)
                tempfile.close()
                print "\x1b[2J",
                return 0
            if args[0] == ":load":
                self.filename = args[1].strip()
                with open(self.filename,'r') as newfile:
                    content = newfile.read()
                #newfile.close()
                #self.current_log = content
                pos = get_list(content)
                temp.pixels = [pixel(i) for i in pos]
        elif len(args) == 1:
            if arg[0] == ':w':
                tempfile = open(self.filename,'wb')
                tempfile.write(self.data)
                tempfile.close()
        print "\x1b[2K",
Esempio n. 4
0
From the chEMBL python client the data for drug, ATC_code and synonymous will be extracted. In adittion, the data for code and has_code will be extracted with an API from EBI to cross_reference.
The sider Database has a different identifiers for the drugs --> STITCH,therefore this needs to be changed to chEMBL. However they do not have any other identifier in the relationship between chemicals and disease file. So the way to solve this problem is to download a file called drug_atc, this allows to map the STITCH id to ATC code, that already is kept in the database."""
import requests
import gzip
import csv
import itertools
import re
import conection_DISNET_drugslayer
from get_list import get_list
cursor = conection_DISNET_drugslayer.cursor


# Get tables phenotype_effect and drug_phenotype_effect
# pe --> phenotype effect

pe_table = get_list("select * from phenotype_effect where source_id = 2")
drug_pe_table = get_list("select * from drug_phenotype_effect where source_id =2")

# Get the primary keys (pk) of phenotype effect and drug- phenotype effect tables 

pe_pk_table = get_list("select phenotype_id, source_id from phenotype_effect where source_id = 2")
drug_pe_pk_table = get_list("select phenotype_id, drug_id, source_id from drug_phenotype_effect where source_id = 2")


# links where the data are, and their names
url_drug_atc = 'http://sideeffects.embl.de/media/download/drug_atc.tsv'
file_name_drug_atc='drug_atc.tsv'

url_side_effects = 'http://sideeffects.embl.de/media/download/meddra_freq.tsv.gz'
file_name_side_effects='meddra_freq.tsv.gz'
has_code_umls_list = []
code_orphan_list = []
has_code_orphan_list = []

# These Lists are going to keep tuples with the data which will be inserted in the tables
new_list_code_umls = []
new_list_code_orphan = []
new_list_has_code_umls = []

# Counts for get the quantity of INSERT, UPDATE and DELETE
n_ins_code = 0
n_ins_orphan = 0
n_ins_orphan_umls = 0

# Get the list of the diseases
disease_list = get_list(
    "select resource_id, disease_id, disease_name from disease")

# Get orphan Dic Mesh
dic = {}
orphan_dic = get_orhpan_code.orphan_codes(dic, 'MeSH')

# Get the list of Phenotype_effect
phenotype_effect = get_list(
    "select distinct phenotype_id from phenotype_effect")
phenotype_effect = list(*zip(*phenotype_effect))

# Get orphan Dic UMLS
dic2 = {}
orphan_dic_UMLS = get_orhpan_code.orphan_codes(dic2, 'UMLS')

# Get the list of the ids which have already UMLS id
This module  works in order to get indication information and insert them into DISNET drugslayer database.

It fills 3 tables: phenotype_effect, code and has_code.

From the chEMBL python client the data for phenotype_effect are extracted.

The data for code and has_code are extracted with an API from UMLS Terminology Services REST API."""

import get_umls
import conection_DISNET_drugslayer
from get_list import get_list
cursor = conection_DISNET_drugslayer.cursor

# Get the de MeSH code and the UMLS code from the Previous Version of has_code table, and create a diccionary with MeSH as key and Code as  value
PV_has_code_table = get_list(
    "select id,code from has_code where resource_id = 121")

# Get Previous Version  of code table
PV_code_table = get_list("select code from code where resource_id = 121")
PV_code_table = list(*zip(*PV_code_table))

# Get the primary keys (pk) from drug_phenotype_effect table Previous Version
# pe --> phenotype effect
PV_PK_pe_table = get_list("select phenotype_id from phenotype_effect")
PV_PK_pe_table = list(*zip(*PV_PK_pe_table))

# Get the Previous Version from drug_phenotype_effect table
# pe --> phenotype effect
PV_pe_table = get_list("select * from phenotype_effect")

# Cross reference dictionary
All the data are extracted from chEMBL python client.
"""

import requests
import gzip
import csv
import itertools
import re
import get_umls
import conection_DISNET_drugslayer
from get_list import get_list

cursor = conection_DISNET_drugslayer.cursor

# Get the de MeSH code and the UMLS code from the Previous Version of has_code table, and create a dictionary with MeSH as key and Code as  value
PV_has_code_table = get_list(
    "select id,code from has_code where resource_id = 121")
mesh_umls_dic = {}

for i in PV_has_code_table:
    mesh_code = i[0]
    umls_code = i[1]
    mesh_umls_dic[mesh_code] = umls_code

# Get the parent table (drug) from the database in order to obtain the indication just for the approved ones, these data will be keep in a list
parent_drug_table = get_list("select distinct drug_id from drug")
parent_drug_table = list(*zip(*parent_drug_table))

# Get the primary keys (pk) from drug_phenotype_effect table Previous Version
PV_PK_drug_pe_table = get_list(
    "select phenotype_id, drug_id, source_id from drug_phenotype_effect where phenotype_type = 'INDICATION'"
)
Esempio n. 8
0
# from segnet import SegNet
from keras.callbacks import TensorBoard, ModelCheckpoint, ReduceLROnPlateau
from keras.utils import plot_model
from unet_model import get_unet

batch_size = 12
n_classes = 2
EPOCH = 100
img_W = 160
img_H = 240
input_shape = (img_W, img_H)

train_file_path = 'raw/train/'
test_file_path = 'raw/test/'

train_image_list, train_label_list = get_list(file_path=train_file_path)
test_image_list, test_label_list = get_list(file_path=test_file_path)

train_list = np.vstack((train_image_list, train_label_list))
train_list = np.transpose(train_list)

# test_list = np.vstack((test_image_list, test_label_list))
# test_list = np.transpose(test_list)

train_data_generator = mygen(train_list, input_shape, n_classes, batch_size)

val_data_generator = mygen(train_list, input_shape, n_classes, batch_size)

# model = SegNet(input_shape, n_classes)
model = get_unet(input_shape=(input_shape[0], input_shape[1], 1),
                 n_class=n_classes)
Esempio n. 9
0
            for i in range(a):
                orphan_number=(data[key][0]['DisorderList'][0]['Disorder'][i]['OrphaNumber'])
                counts=data[key][0]['DisorderList'][0]['Disorder'][i]['ExternalReferenceList'][0]['count']
                counts=int(counts)
                if counts >1:
                    for j in range(counts):
                        links = data[key][0]['DisorderList'][0]['Disorder'][i]['ExternalReferenceList'][0]['ExternalReference'][j]
                        if links['Source'] == source:
                            reference=(links['Reference'])
                            orphan_dic[reference]=[orphan_number][0]
                if counts ==1:
                    links=data[key][0]['DisorderList'][0]['Disorder'][i]['ExternalReferenceList'][0]['ExternalReference'][0]
                    if links['Source'] == source:
                        reference=(links['Reference'])
                        orphan_dic[reference]=[orphan_number][0]
    return orphan_dic

phenotype_effect = get_list("select distinct phenotype_id from phenotype_effect")
phenotype_effect=list(*zip(*phenotype_effect))
orphan_dic = orphan_codes(orphan_dic = {})

news=[]
for i in phenotype_effect:
    if i in orphan_dic.keys():
        a=(i,orphan_dic[i])
        news.append(a)
print(news)
print(len(news))


    """
    myfile = requests.get(url)
    if myfile.status_code == 200:
        open(file_name, 'wb').write(myfile.content)
    else:
        print('The link does not work')


# Download the file CTD_chemicals_diseases and CTD_chemicals file, this file contains the drugs and the related diseases
request_url(url_chemical_diseases, file_name_chemical_diseases)
request_url(url_chemical, file_name_chemical)

# Get the DrugBank codes of each drug from the has_code table, keep them in a diccionary.
# The  DrugBank id as a key and the chEMBL id as a value
drugbank_chembl = {}
cross_references_list = get_list(
    "SELECT * FROM has_code where entity_id = 2 and resource_id = 95 ")
for i in cross_references_list:
    chembl_code = i[1]
    drugbank_code = i[2]
    drugbank_chembl[drugbank_code] = chembl_code

# Get Previous Version of tables disease and drug_disease
PV_disease_table = get_list("select * from disease")
PV_drug_disease_table = get_list("select *from drug_disease")

# Get the primary keys (pk) from the disease and drug disease Previous Version of tables
PV_PK_disease_table = get_list("select disease_id from disease")
PV_PK_disease_table = list(*zip(*PV_PK_disease_table))
PV_PK_drug_disease_table = get_list(
    "select disease_id, drug_id from drug_disease")
Esempio n. 11
0
from get_list import get_list
company_df=get_list()

for one in company_df.iloc[:,0]:
    print(one)
Esempio n. 12
0
cursor = conection_DISNET_drugslayer.cursor

# Initialize auxiliaries
count_umls = 0
count_orphanet = 0

complete_list_code_umls = []
code_umls_list = []
has_code_umls_list = []

complete_list_code_orphan = []
code_orphan_list = []
has_code_orphan_list = []

# Get the list of the diseases
disease_list = get_list(
    "select resource_id, disease_id, disease_name from disease")
orphan_dic = get_orhpan_code.orphan_codes(orphan_dic={})

# Get the list of the ids which have already UMLS id
has_code_table = get_list(" select id from has_code where resource_id = 121")
has_code_table = list(*zip(*has_code_table))

code_table = get_list(" select code from code where resource_id = 121")
code_table = list(*zip(*code_table))

code_table_orphan = get_list(" select code from code where resource_id = 99")
code_table_orphan = list(*zip(*code_table_orphan))

# Resource id
UMLS_RESOURCE_ID = 121
ORPHAN_RESOURCE_ID = 99
Esempio n. 13
0
"""Drug Target Table.

This module works in order to get the information about the relation of the drugs and the targets of the drugs and insert them into DISNET drugslayer database.

It fills 1 table: drug_target.

All the data are extracted from chEMBL python client.
"""

import conection_DISNET_drugslayer
from get_list import get_list
cursor = conection_DISNET_drugslayer.cursor

# Get primary keys (pk) from the parent tables (drug and target)
parent_drug_table = get_list("select distinct drug_id from drug")
parent_drug_table = list(*zip(*parent_drug_table))

parent_target_table = get_list("select distinct target_id from target")
parent_target_table = list(*zip(*parent_target_table))

# Get the Previous Version of drug_target table.
PV_drug_target_table = get_list("select * from drug_target")

# Get the primary keys (pk) of drug_target table Previous Version.
PV_PK_drug_target_table = get_list(
    "select target_id, drug_id from drug_target")

# Initialize auxiliaries

# Count for keeping the quantity of data that are going to be inserted
count = 0
Esempio n. 14
0
The data for code and has_code are got from UNICHEM python client to get the cross reference between chEMBL and DrugBank .


"""
import csv
import itertools
import zipfile
import urllib.request
import requests
import conection_DISNET_drugslayer
from get_list import get_list

cursor = conection_DISNET_drugslayer.cursor

# Get Previous Version of drug table
PV_drug_table = get_list("select * from drug")

# get column length
column_length = len(PV_drug_table[0])

# Get the primary keys (PK) from Previous Version of drug table
PV_PK_drug_table = get_list("select drug_id from drug")
PV_PK_drug_table = list(*zip(*PV_PK_drug_table))

# Get code from has_code table
has_code_table = get_list("select code from has_code where resource_id = 95")
has_code_table = list(*zip(*has_code_table))

# Get Previous Version of ATC_code table
PV_ATC_table = get_list("select * from ATC_code")
""" The function of this module works in order to get drug information and insert them into DISNET drugslayer database.
this module will fill 5 tables: drug, ATC_code, code, has_code and synonymous.

From the chEMBL python client the data for drug, ATC_code and synonymous will be extracted. In adittion, the data for code and has_code will be extracted with an API from EBI to cross_reference.
"""

import requests
import conection_DISNET_drugslayer
from get_list import get_list
cursor = conection_DISNET_drugslayer.cursor

# Get drug table
drug_table = get_list("select * from drug")

# get column length
column_length=len(drug_table[0])

# Get the primary keys (pk) from drug table 
drug_pk_table = get_list("select drug_id from drug")
drug_pk_table=list(*zip(*drug_pk_table))

# Get ATC_code table
ATC_table = get_list("select * from ATC_code")

# Get synonymous table
synonymous_table = get_list("select * from synonymous")

# Get columns names
columns_names = get_list("""SELECT COLUMN_NAME FROM information_schema.COLUMNS 
                        WHERE TABLE_SCHEMA LIKE 'disnet_drugslayer' AND TABLE_NAME = 'drug' """)