Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ippidb-web
Manage
Activity
Members
Labels
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
1808807b
Commit
1808807b
authored
7 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
start script options for migration of Compound
(start working on #18)
parent
944249f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+32
-2
32 additions, 2 deletions
ippisite/ippidb/management/commands/import_v1_data.py
with
32 additions
and
2 deletions
ippisite/ippidb/management/commands/import_v1_data.py
+
32
−
2
View file @
1808807b
...
...
@@ -2,7 +2,8 @@ from django.core.management import BaseCommand, CommandError
import
mysql.connector
from
ippidb.models
import
Bibliography
,
Protein
,
Taxonomy
,
MolecularFunction
,
\
Domain
,
ProteinDomainBoundComplex
,
ProteinDomainPartnerComplex
,
Symmetry
,
Ppi
,
PpiComplex
,
Disease
Domain
,
ProteinDomainBoundComplex
,
ProteinDomainPartnerComplex
,
Symmetry
,
Ppi
,
PpiComplex
,
Disease
,
\
Compound
class
Command
(
BaseCommand
):
...
...
@@ -44,6 +45,13 @@ class Command(BaseCommand):
default
=
False
,
help
=
'
Flush and migrate ppis and complexes
'
,
)
parser
.
add_argument
(
'
--compound
'
,
action
=
'
store_true
'
,
dest
=
'
compound
'
,
default
=
False
,
help
=
'
Flush and migrate compounds
'
,
)
parser
.
add_argument
(
'
--stoponfail
'
,
action
=
'
store_true
'
,
...
...
@@ -203,4 +211,26 @@ select distinct protein.NumUniprot, domain.PfamNumAccession , complexe.NbCopy,
self
.
stdout
.
write
(
self
.
style
.
ERROR
(
'
Failed inserting {} {}
'
.
format
(
row
[
0
],
row
[
1
])))
else
:
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully inserted {} {}
'
.
format
(
row
[
0
],
row
[
1
])))
if
options
[
'
compound
'
]:
cursor
.
execute
(
"""
SELECT * FROM compound
"""
)
rows
=
cursor
.
fetchall
()
Compound
.
objects
.
all
().
delete
()
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully flushed compound table
'
))
for
row
in
rows
:
try
:
compound
=
Compound
()
compound
.
canonical_smile
=
row
[
1
]
compound
.
is_macrocycle
=
(
row
[
4
]
==
'
Y
'
)
compound
.
aromatic_ratio
=
row
[
5
]
compound
.
balaban_index
=
row
[
6
]
compound
.
balaban_index
=
row
[
6
]
compound
.
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%
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