Skip to content
Snippets Groups Projects
Commit f209b66f authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

migrate TestCytotoxicityDescription (fix #28)

Former-commit-id: 67806cbeb81fdcc7428cb60b69155b7531f002e7
parent 188b35ab
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,8 @@ import mysql.connector ...@@ -6,7 +6,8 @@ import mysql.connector
from ippidb.models import Bibliography, Protein, Taxonomy, MolecularFunction, \ from ippidb.models import Bibliography, Protein, Taxonomy, MolecularFunction, \
Domain, ProteinDomainBoundComplex, ProteinDomainPartnerComplex, Symmetry, Ppi, PpiComplex, Disease, \ Domain, ProteinDomainBoundComplex, ProteinDomainPartnerComplex, Symmetry, Ppi, PpiComplex, Disease, \
Compound, MDDRCompoundImport, MDDRActivityClass, TestActivityDescription, CellLine, RefCompoundBiblio, CompoundAction Compound, MDDRCompoundImport, MDDRActivityClass, TestActivityDescription, CellLine, RefCompoundBiblio, \
CompoundAction, TestCytotoxDescription
class MyConverter(mysql.connector.conversion.MySQLConverter): class MyConverter(mysql.connector.conversion.MySQLConverter):
...@@ -313,12 +314,14 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy, ...@@ -313,12 +314,14 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
else: else:
self.stdout.write( self.stdout.write(
self.style.SUCCESS('Successfully inserted {} {}'.format(row[0], row[1]))) self.style.SUCCESS('Successfully inserted {} {}'.format(row[0], row[1])))
CellLine.objects.all().delete()
self.stdout.write(
self.style.SUCCESS('Successfully flushed cell lines table'))
cursor.execute("""SELECT * FROM testActivityDescription""") cursor.execute("""SELECT * FROM testActivityDescription""")
rows = cursor.fetchall() rows = cursor.fetchall()
TestActivityDescription.objects.all().delete() TestActivityDescription.objects.all().delete()
CellLine.objects.all().delete()
self.stdout.write( self.stdout.write(
self.style.SUCCESS('Successfully flushed test activity descriptions table and cell lines table')) self.style.SUCCESS('Successfully flushed test activity descriptions table'))
for row in rows: for row in rows:
try: try:
tad = TestActivityDescription() tad = TestActivityDescription()
...@@ -348,6 +351,37 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy, ...@@ -348,6 +351,37 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
else: else:
self.stdout.write( self.stdout.write(
self.style.SUCCESS('Successfully inserted {}'.format(row[2]))) self.style.SUCCESS('Successfully inserted {}'.format(row[2])))
cursor.execute("""SELECT * FROM testCytotoxDescription""")
rows = cursor.fetchall()
TestCytotoxDescription.objects.all().delete()
self.stdout.write(
self.style.SUCCESS('Successfully flushed test cytotoxicity descriptions table'))
for row in rows:
try:
tcd = TestCytotoxDescription()
cursor.execute(
"""select IDSource from biblio where IDBiblio={}""".format(row[1]))
biblio_row = cursor.fetchone()
biblio = Bibliography.objects.get(id_source=biblio_row[0])
tcd.biblio = biblio
tcd.test_name = row[2]
tcd.compound_concentration = row[4]
if row[3] is not None:
tcd.cell_line, created = CellLine.objects.get_or_create(
name=row[3])
tcd.save()
except Exception as e:
if options['stoponfail']:
import traceback
self.stderr.write(traceback.format_exc())
raise CommandError(
'Failed inserting {} {}'.format(row[1], row[2]))
else:
self.stdout.write(
self.style.ERROR('Failed inserting {} {}'.format(row[1], row[2])))
else:
self.stdout.write(
self.style.SUCCESS('Successfully inserted {}'.format(row[2])))
if options['mddr']: if options['mddr']:
from pybel import readfile from pybel import readfile
MDDRCompoundImport.objects.all().delete() MDDRCompoundImport.objects.all().delete()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment