Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iPPIDB
ippidb-web
Commits
07987c12
Commit
07987c12
authored
7 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
migrate compound-bibliography data
Former-commit-id: b315278b18e80d3ccb5947e6bb6ad27f96c7a241
parent
dafb5340
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ippisite/ippidb/management/commands/import_v1_data.py
+36
-2
36 additions, 2 deletions
ippisite/ippidb/management/commands/import_v1_data.py
with
36 additions
and
2 deletions
ippisite/ippidb/management/commands/import_v1_data.py
+
36
−
2
View file @
07987c12
...
...
@@ -3,11 +3,10 @@ import glob
from
django.utils
import
timezone
from
django.core.management
import
BaseCommand
,
CommandError
import
mysql.connector
from
pybel
import
readfile
from
ippidb.models
import
Bibliography
,
Protein
,
Taxonomy
,
MolecularFunction
,
\
Domain
,
ProteinDomainBoundComplex
,
ProteinDomainPartnerComplex
,
Symmetry
,
Ppi
,
PpiComplex
,
Disease
,
\
Compound
,
MDDRCompoundImport
,
MDDRActivityClass
,
TestActivityDescription
,
CellLine
Compound
,
MDDRCompoundImport
,
MDDRActivityClass
,
TestActivityDescription
,
CellLine
,
RefCompoundBiblio
class
MyConverter
(
mysql
.
connector
.
conversion
.
MySQLConverter
):
...
...
@@ -77,6 +76,13 @@ class Command(BaseCommand):
default
=
False
,
help
=
'
Flush and migrate compounds
'
,
)
parser
.
add_argument
(
'
--compound-biblio
'
,
action
=
'
store_true
'
,
dest
=
'
compoundbiblio
'
,
default
=
False
,
help
=
'
Flush and migrate compounds-bibliography
'
,
)
parser
.
add_argument
(
'
--test-activity-description
'
,
action
=
'
store_true
'
,
...
...
@@ -301,6 +307,7 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully inserted {}
'
.
format
(
row
[
2
])))
if
options
[
'
mddr
'
]:
from
pybel
import
readfile
MDDRCompoundImport
.
objects
.
all
().
delete
()
MDDRActivityClass
.
objects
.
all
().
delete
()
self
.
stdout
.
write
(
...
...
@@ -409,3 +416,30 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
else
:
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully inserted {} {}
'
.
format
(
row
[
1
],
row
[
2
])))
if
options
[
'
compoundbiblio
'
]:
cursor
.
execute
(
"""
select r.CmpdNameInBiblio, c.CanonicalSmile, b.IDSource from refCmpdBiblio as r inner join compound as c on r.IDCompound=c.IDCompound inner join biblio as b on r.IDBiblio=b.IDBiblio;
"""
)
rows
=
cursor
.
fetchall
()
RefCompoundBiblio
.
objects
.
all
().
delete
()
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully flushed compound-biblio table
'
))
for
row
in
rows
:
try
:
c
=
Compound
.
objects
.
get
(
canonical_smile
=
row
[
1
])
b
=
Bibliography
.
objects
.
get
(
id_source
=
row
[
2
])
r
=
RefCompoundBiblio
()
r
.
compound_id
=
c
.
id
r
.
bibliography_id
=
b
.
id
r
.
compound_name
=
row
[
0
]
r
.
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
[
1
],
row
[
2
])))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment