diff --git a/djangoAPI/__pycache__/settings.cpython-39.pyc b/djangoAPI/__pycache__/settings.cpython-39.pyc index e999f5b..fd1c095 100644 Binary files a/djangoAPI/__pycache__/settings.cpython-39.pyc and b/djangoAPI/__pycache__/settings.cpython-39.pyc differ diff --git a/djangoAPI/__pycache__/tasks.cpython-39.pyc b/djangoAPI/__pycache__/tasks.cpython-39.pyc index b64b2e3..7704b3f 100644 Binary files a/djangoAPI/__pycache__/tasks.cpython-39.pyc and b/djangoAPI/__pycache__/tasks.cpython-39.pyc differ diff --git a/djangoAPI/__pycache__/urls.cpython-39.pyc b/djangoAPI/__pycache__/urls.cpython-39.pyc index 04a559f..6a035af 100644 Binary files a/djangoAPI/__pycache__/urls.cpython-39.pyc and b/djangoAPI/__pycache__/urls.cpython-39.pyc differ diff --git a/djangoAPI/settings.py b/djangoAPI/settings.py index 1738135..1a4d965 100755 --- a/djangoAPI/settings.py +++ b/djangoAPI/settings.py @@ -116,7 +116,7 @@ 'NAME': config("POSTGRES_DB"), 'USER': config("POSTGRES_USER"), 'PASSWORD': config("POSTGRES_PASSWORD"), - 'HOST': 'db', + 'HOST': '172.26.0.2', 'PORT': '5432', } } diff --git a/djangoAPI/tasks.py b/djangoAPI/tasks.py index 245d5c6..f753d92 100755 --- a/djangoAPI/tasks.py +++ b/djangoAPI/tasks.py @@ -7,6 +7,7 @@ app = Celery("djangoAPI") app.config_from_object('django.conf:settings', namespace="CELERY") + app.autodiscover_tasks() @app.task diff --git a/djangoAPI/urls.py b/djangoAPI/urls.py index bd99561..16c79fe 100755 --- a/djangoAPI/urls.py +++ b/djangoAPI/urls.py @@ -6,14 +6,12 @@ from fiocruz import views router = routers.DefaultRouter() -router.register(r'back/VS_doking2', views.VS_ViewSet, basename='admin') -router.register(r'process-plasmodocking', views.ProcessPlasmodockingViewSet) +router.register(r'back/process-plasmodocking', views.ProcessPlasmodockingViewSet) urlpatterns = [ path('', include(router.urls)), path('admin/', admin.site.urls), path('api-auth/', include('rest_framework.urls')), - path('back/VS_doking/', views.upload_view, name='upload_view'), path('back/api_delete//', views.api_delete, name='api_delete'), path('back/api_download//', views.download_file, name='api_download'), path('back/get_resultado//', views.get_resultado, name='get_resultado'), diff --git a/fiocruz/__pycache__/admin.cpython-39.pyc b/fiocruz/__pycache__/admin.cpython-39.pyc index 1e669c4..05f7c5a 100644 Binary files a/fiocruz/__pycache__/admin.cpython-39.pyc and b/fiocruz/__pycache__/admin.cpython-39.pyc differ diff --git a/fiocruz/__pycache__/models.cpython-39.pyc b/fiocruz/__pycache__/models.cpython-39.pyc index db6a11c..ad96857 100644 Binary files a/fiocruz/__pycache__/models.cpython-39.pyc and b/fiocruz/__pycache__/models.cpython-39.pyc differ diff --git a/fiocruz/__pycache__/serializers.cpython-39.pyc b/fiocruz/__pycache__/serializers.cpython-39.pyc index c31109d..c4135dd 100644 Binary files a/fiocruz/__pycache__/serializers.cpython-39.pyc and b/fiocruz/__pycache__/serializers.cpython-39.pyc differ diff --git a/fiocruz/__pycache__/tasks.cpython-39.pyc b/fiocruz/__pycache__/tasks.cpython-39.pyc index 19a88f4..9a931c4 100644 Binary files a/fiocruz/__pycache__/tasks.cpython-39.pyc and b/fiocruz/__pycache__/tasks.cpython-39.pyc differ diff --git a/fiocruz/__pycache__/views.cpython-39.pyc b/fiocruz/__pycache__/views.cpython-39.pyc index 5542ac1..5977c6c 100644 Binary files a/fiocruz/__pycache__/views.cpython-39.pyc and b/fiocruz/__pycache__/views.cpython-39.pyc differ diff --git a/fiocruz/admin.py b/fiocruz/admin.py index 2afac00..cb9b316 100755 --- a/fiocruz/admin.py +++ b/fiocruz/admin.py @@ -1,8 +1,8 @@ from django.contrib import admin -from .models import Process_Plasmodocking, Macromoleculas_virtaulS, UserCustom, Macro_Prepare +from .models import MacromoleculesFalciparumWithRedocking, ProcessPlasmodocking, UserCustom, MacroPrepare # Register your models here. -admin.site.register(Process_Plasmodocking) -admin.site.register(Macromoleculas_virtaulS) +admin.site.register(ProcessPlasmodocking) +admin.site.register(MacromoleculesFalciparumWithRedocking) admin.site.register(UserCustom) -admin.site.register(Macro_Prepare) \ No newline at end of file +admin.site.register(MacroPrepare) \ No newline at end of file diff --git a/fiocruz/migrations/0001_initial.py b/fiocruz/migrations/0001_initial.py index d3144ea..d65f35c 100644 --- a/fiocruz/migrations/0001_initial.py +++ b/fiocruz/migrations/0001_initial.py @@ -1,6 +1,7 @@ -# Generated by Django 4.2.4 on 2023-08-28 04:49 +# Generated by Django 4.2.4 on 2024-10-07 00:40 from django.db import migrations, models +import django.db.models.deletion import fiocruz.models import uuid @@ -14,52 +15,103 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='Arquivos_virtaulS', + name='MacromoleculesFalciparumWithoutRedocking', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('nome', models.CharField(max_length=200)), - ('user', models.TextField()), - ('ligante', models.FileField(blank=True, null=True, upload_to=fiocruz.models.ligante_arquivo)), - ('data', models.DateTimeField(auto_now_add=True)), - ('resultado_final', models.TextField(blank=True, null=True)), - ('status', models.BooleanField(default=False)), + ('rec', models.CharField(max_length=200)), + ('rec_fld', models.FileField(upload_to=fiocruz.models.macromolecule_upload_path)), + ('gridsize', models.CharField(blank=True, max_length=200, null=True)), + ('gridcenter', models.CharField(blank=True, max_length=200, null=True)), + ('redocking', models.BooleanField(default=False)), ], + options={ + 'db_table': 'macromolecules_falciparum_without_redocking', + }, ), migrations.CreateModel( - name='Macromoleculas_virtaulS', + name='MacromoleculesFalciparumWithRedocking', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('nome', models.CharField(max_length=200)), ('rec', models.CharField(max_length=200)), - ('rec_fld', models.FileField(upload_to='macromoleculas_virtualS')), + ('rec_fld', models.FileField(upload_to=fiocruz.models.macromolecule_upload_path)), + ('gridsize', models.CharField(blank=True, max_length=200, null=True)), + ('gridcenter', models.CharField(blank=True, max_length=200, null=True)), ('ligante_original', models.CharField(blank=True, max_length=200, null=True)), - ('rmsd_redoking', models.CharField(blank=True, max_length=200, null=True)), - ('energia_orinal', models.CharField(blank=True, max_length=200, null=True)), + ('rmsd_redocking', models.CharField(blank=True, max_length=200, null=True)), + ('energia_original', models.CharField(blank=True, max_length=200, null=True)), + ('redocking', models.BooleanField(default=True)), + ], + options={ + 'db_table': 'macromolecules_falciparum_with_redocking', + }, + ), + migrations.CreateModel( + name='MacromoleculesVivaxWithRedocking', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome', models.CharField(max_length=200)), + ('rec', models.CharField(max_length=200)), + ('rec_fld', models.FileField(upload_to=fiocruz.models.macromolecule_upload_path)), ('gridsize', models.CharField(blank=True, max_length=200, null=True)), ('gridcenter', models.CharField(blank=True, max_length=200, null=True)), + ('ligante_original', models.CharField(blank=True, max_length=200, null=True)), + ('rmsd_redocking', models.CharField(blank=True, max_length=200, null=True)), + ('energia_original', models.CharField(blank=True, max_length=200, null=True)), + ('redocking', models.BooleanField(default=True)), ], + options={ + 'db_table': 'macromolecules_vivax_with_redocking', + }, ), migrations.CreateModel( - name='Testes', + name='MacroPrepare', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('processo_name', models.CharField(max_length=200, null=True)), ('nome', models.CharField(max_length=200)), + ('rec', models.CharField(max_length=200)), + ('receptor_pdb', models.FileField(upload_to=fiocruz.models.arquivo)), + ('receptor_pdbqt', models.FileField(null=True, upload_to=fiocruz.models.arquivo)), + ('ligante_pdb', models.FileField(null=True, upload_to=fiocruz.models.arquivo)), + ('gridsize', models.CharField(blank=True, max_length=200, null=True)), + ('gridcenter', models.CharField(blank=True, max_length=200, null=True)), ], ), migrations.CreateModel( name='UserCustom', fields=[ - ('id', models.TextField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), + ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('email', models.EmailField(max_length=254, unique=True)), - ('username', models.CharField(max_length=255, unique=True)), + ('name', models.CharField(max_length=255)), ('password', models.CharField(max_length=255)), - ('name', models.CharField(max_length=255, null=True)), + ('username', models.CharField(max_length=255, unique=True)), ('active', models.BooleanField(default=False)), ('deleted', models.BooleanField(default=False)), - ('role', models.CharField(default='USER', max_length=50)), + ('role', models.CharField(choices=[('USER', 'User'), ('ADMIN', 'Admin')], default='USER', max_length=255)), + ('created_at', models.DateTimeField(auto_now_add=True)), + ('updated_at', models.DateTimeField(auto_now=True)), ], options={ 'db_table': 'users', }, ), + migrations.CreateModel( + name='ProcessPlasmodocking', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nome', models.CharField(max_length=200)), + ('ligante', models.FileField(blank=True, null=True, upload_to=fiocruz.models.ligante_arquivo)), + ('data', models.DateTimeField(auto_now_add=True)), + ('resultado_final', models.TextField(default='Sem resultados')), + ('status', models.CharField(choices=[('em fila', 'Em fila'), ('processando', 'Processando'), ('concluido', 'Concluído'), ('error', 'Erro')], default='em fila', max_length=20)), + ('type', models.CharField(choices=[('vivax', 'Vivax'), ('falciparum', 'Falciparum')], default='falciparum', max_length=20)), + ('redocking', models.BooleanField(default=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiocruz.usercustom')), + ], + options={ + 'db_table': 'process_plasmodocking', + }, + ), ] diff --git a/fiocruz/migrations/0002_alter_arquivos_virtauls_table.py b/fiocruz/migrations/0002_alter_macroprepare_table.py similarity index 63% rename from fiocruz/migrations/0002_alter_arquivos_virtauls_table.py rename to fiocruz/migrations/0002_alter_macroprepare_table.py index 786fbeb..dc62e0d 100644 --- a/fiocruz/migrations/0002_alter_arquivos_virtauls_table.py +++ b/fiocruz/migrations/0002_alter_macroprepare_table.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.4 on 2023-08-28 04:51 +# Generated by Django 4.2.4 on 2024-10-07 00:43 from django.db import migrations @@ -11,7 +11,7 @@ class Migration(migrations.Migration): operations = [ migrations.AlterModelTable( - name='arquivos_virtauls', - table='Arquivos_virtaulS', + name='macroprepare', + table='macro_prepare', ), ] diff --git a/fiocruz/migrations/0003_delete_usercustom.py b/fiocruz/migrations/0003_delete_usercustom.py deleted file mode 100644 index 267ce46..0000000 --- a/fiocruz/migrations/0003_delete_usercustom.py +++ /dev/null @@ -1,16 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-28 05:00 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0002_alter_arquivos_virtauls_table'), - ] - - operations = [ - migrations.DeleteModel( - name='UserCustom', - ), - ] diff --git a/fiocruz/migrations/0004_usercustom.py b/fiocruz/migrations/0004_usercustom.py deleted file mode 100644 index f591c0b..0000000 --- a/fiocruz/migrations/0004_usercustom.py +++ /dev/null @@ -1,30 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-28 05:02 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0003_delete_usercustom'), - ] - - operations = [ - migrations.CreateModel( - name='UserCustom', - fields=[ - ('id', models.TextField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('email', models.EmailField(max_length=254, unique=True)), - ('username', models.CharField(max_length=255, unique=True)), - ('password', models.CharField(max_length=255)), - ('name', models.CharField(max_length=255, null=True)), - ('active', models.BooleanField(default=False)), - ('deleted', models.BooleanField(default=False)), - ('role', models.CharField(default='USER', max_length=50)), - ], - options={ - 'db_table': 'users', - }, - ), - ] diff --git a/fiocruz/migrations/0005_alter_arquivos_virtauls_user.py b/fiocruz/migrations/0005_alter_arquivos_virtauls_user.py deleted file mode 100644 index 9728be0..0000000 --- a/fiocruz/migrations/0005_alter_arquivos_virtauls_user.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 4.2.4 on 2023-08-30 04:12 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0004_usercustom'), - ] - - operations = [ - migrations.AlterField( - model_name='arquivos_virtauls', - name='user', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiocruz.usercustom'), - ), - ] diff --git a/fiocruz/migrations/0006_remove_arquivos_virtauls_resultado_final_and_more.py b/fiocruz/migrations/0006_remove_arquivos_virtauls_resultado_final_and_more.py deleted file mode 100644 index 4c45a18..0000000 --- a/fiocruz/migrations/0006_remove_arquivos_virtauls_resultado_final_and_more.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-03 04:16 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0005_alter_arquivos_virtauls_user'), - ] - - operations = [ - migrations.RemoveField( - model_name='arquivos_virtauls', - name='resultado_final', - ), - migrations.AddField( - model_name='arquivos_virtauls', - name='dada_docking', - field=models.JSONField(blank=True, null=True), - ), - ] diff --git a/fiocruz/migrations/0007_remove_arquivos_virtauls_dada_docking_and_more.py b/fiocruz/migrations/0007_remove_arquivos_virtauls_dada_docking_and_more.py deleted file mode 100644 index 5ff0837..0000000 --- a/fiocruz/migrations/0007_remove_arquivos_virtauls_dada_docking_and_more.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-03 04:25 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0006_remove_arquivos_virtauls_resultado_final_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='arquivos_virtauls', - name='dada_docking', - ), - migrations.AddField( - model_name='arquivos_virtauls', - name='resultado_final', - field=models.TextField(blank=True, null=True), - ), - ] diff --git a/fiocruz/migrations/0008_remove_arquivos_virtauls_resultado_final.py b/fiocruz/migrations/0008_remove_arquivos_virtauls_resultado_final.py deleted file mode 100644 index 002dd0c..0000000 --- a/fiocruz/migrations/0008_remove_arquivos_virtauls_resultado_final.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-05 03:28 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0007_remove_arquivos_virtauls_dada_docking_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='arquivos_virtauls', - name='resultado_final', - ), - ] diff --git a/fiocruz/migrations/0009_arquivos_virtauls_resultado_final.py b/fiocruz/migrations/0009_arquivos_virtauls_resultado_final.py deleted file mode 100644 index e5ad5c5..0000000 --- a/fiocruz/migrations/0009_arquivos_virtauls_resultado_final.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-05 03:43 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0008_remove_arquivos_virtauls_resultado_final'), - ] - - operations = [ - migrations.AddField( - model_name='arquivos_virtauls', - name='resultado_final', - field=models.TextField(blank=True, null=True), - ), - ] diff --git a/fiocruz/migrations/0010_rename_username_usercustom_firtname.py b/fiocruz/migrations/0010_rename_username_usercustom_firtname.py deleted file mode 100644 index c4729cc..0000000 --- a/fiocruz/migrations/0010_rename_username_usercustom_firtname.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-11 16:39 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0009_arquivos_virtauls_resultado_final'), - ] - - operations = [ - migrations.RenameField( - model_name='usercustom', - old_name='username', - new_name='firtname', - ), - ] diff --git a/fiocruz/migrations/0011_rename_firtname_usercustom_firstname.py b/fiocruz/migrations/0011_rename_firtname_usercustom_firstname.py deleted file mode 100644 index 64cb4f9..0000000 --- a/fiocruz/migrations/0011_rename_firtname_usercustom_firstname.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-11 16:41 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0010_rename_username_usercustom_firtname'), - ] - - operations = [ - migrations.RenameField( - model_name='usercustom', - old_name='firtname', - new_name='firstname', - ), - ] diff --git a/fiocruz/migrations/0012_rename_firstname_usercustom_username.py b/fiocruz/migrations/0012_rename_firstname_usercustom_username.py deleted file mode 100644 index 81c42aa..0000000 --- a/fiocruz/migrations/0012_rename_firstname_usercustom_username.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-11 17:21 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0011_rename_firtname_usercustom_firstname'), - ] - - operations = [ - migrations.RenameField( - model_name='usercustom', - old_name='firstname', - new_name='username', - ), - ] diff --git a/fiocruz/migrations/0013_rename_username_usercustom_firstname.py b/fiocruz/migrations/0013_rename_username_usercustom_firstname.py deleted file mode 100644 index 4386c35..0000000 --- a/fiocruz/migrations/0013_rename_username_usercustom_firstname.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-11 17:51 - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0012_rename_firstname_usercustom_username'), - ] - - operations = [ - migrations.RenameField( - model_name='usercustom', - old_name='username', - new_name='firstname', - ), - ] diff --git a/fiocruz/migrations/0014_macro_prepare_and_more.py b/fiocruz/migrations/0014_macro_prepare_and_more.py deleted file mode 100644 index 721f2b8..0000000 --- a/fiocruz/migrations/0014_macro_prepare_and_more.py +++ /dev/null @@ -1,36 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-14 06:17 - -from django.db import migrations, models -import fiocruz.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0013_rename_username_usercustom_firstname'), - ] - - operations = [ - migrations.CreateModel( - name='Macro_Prepare', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nome', models.CharField(max_length=200)), - ('rec', models.CharField(max_length=200)), - ('recptorpdb', models.FileField(upload_to=fiocruz.models.arquivo)), - ('recptorpdbqt', models.FileField(upload_to=fiocruz.models.arquivo)), - ('ligantepdb', models.FileField(upload_to=fiocruz.models.arquivo)), - ('centerX', models.FloatField(null=True)), - ('centerY', models.FloatField(null=True)), - ('centerZ', models.FloatField(null=True)), - ('sizeX', models.FloatField(null=True)), - ('sizeY', models.FloatField(null=True)), - ('sizeZ', models.FloatField(null=True)), - ], - ), - migrations.AlterField( - model_name='arquivos_virtauls', - name='resultado_final', - field=models.TextField(default='Sem resultados'), - ), - ] diff --git a/fiocruz/migrations/0015_remove_usercustom_firstname_usercustom_username_and_more.py b/fiocruz/migrations/0015_remove_usercustom_firstname_usercustom_username_and_more.py deleted file mode 100644 index c2f69a8..0000000 --- a/fiocruz/migrations/0015_remove_usercustom_firstname_usercustom_username_and_more.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-23 03:53 - -from django.db import migrations, models -import fiocruz.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0014_macro_prepare_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='usercustom', - name='firstname', - ), - migrations.AddField( - model_name='usercustom', - name='username', - field=models.CharField(max_length=255, null=True), - ), - migrations.AlterField( - model_name='macromoleculas_virtauls', - name='rec_fld', - field=models.FileField(upload_to=fiocruz.models.arquivo_macro), - ), - migrations.AlterField( - model_name='usercustom', - name='name', - field=models.CharField(max_length=255, unique=True), - ), - ] diff --git a/fiocruz/migrations/0016_alter_usercustom_deleted_alter_usercustom_name_and_more.py b/fiocruz/migrations/0016_alter_usercustom_deleted_alter_usercustom_name_and_more.py deleted file mode 100644 index 472b9d8..0000000 --- a/fiocruz/migrations/0016_alter_usercustom_deleted_alter_usercustom_name_and_more.py +++ /dev/null @@ -1,33 +0,0 @@ -# Generated by Django 4.2.4 on 2023-09-25 00:18 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0015_remove_usercustom_firstname_usercustom_username_and_more'), - ] - - operations = [ - migrations.AlterField( - model_name='usercustom', - name='deleted', - field=models.BooleanField(blank=True, default=False, null=True), - ), - migrations.AlterField( - model_name='usercustom', - name='name', - field=models.CharField(max_length=255), - ), - migrations.AlterField( - model_name='usercustom', - name='role', - field=models.CharField(default='USER', max_length=255), - ), - migrations.AlterField( - model_name='usercustom', - name='username', - field=models.CharField(max_length=255, unique=True), - ), - ] diff --git a/fiocruz/migrations/0017_macromoleculas_sem_redocking_delete_testes_and_more.py b/fiocruz/migrations/0017_macromoleculas_sem_redocking_delete_testes_and_more.py deleted file mode 100644 index 793f067..0000000 --- a/fiocruz/migrations/0017_macromoleculas_sem_redocking_delete_testes_and_more.py +++ /dev/null @@ -1,70 +0,0 @@ -# Generated by Django 4.2.4 on 2023-10-27 04:12 - -from django.db import migrations, models -import fiocruz.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0016_alter_usercustom_deleted_alter_usercustom_name_and_more'), - ] - - operations = [ - migrations.CreateModel( - name='Macromoleculas_Sem_Redocking', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nome', models.CharField(max_length=200)), - ('rec', models.CharField(max_length=200)), - ('rec_fld', models.FileField(upload_to=fiocruz.models.arquivo_macro_SR)), - ('gridsize', models.CharField(blank=True, max_length=200, null=True)), - ('gridcenter', models.CharField(blank=True, max_length=200, null=True)), - ], - options={ - 'db_table': 'Macromoleculas_Sem_Redocking', - }, - ), - migrations.DeleteModel( - name='Testes', - ), - migrations.RemoveField( - model_name='macro_prepare', - name='centerX', - ), - migrations.RemoveField( - model_name='macro_prepare', - name='centerY', - ), - migrations.RemoveField( - model_name='macro_prepare', - name='centerZ', - ), - migrations.RemoveField( - model_name='macro_prepare', - name='sizeX', - ), - migrations.RemoveField( - model_name='macro_prepare', - name='sizeY', - ), - migrations.RemoveField( - model_name='macro_prepare', - name='sizeZ', - ), - migrations.AddField( - model_name='arquivos_virtauls', - name='type', - field=models.TextField(default='Com Redocking'), - ), - migrations.AddField( - model_name='macro_prepare', - name='gridcenter', - field=models.CharField(blank=True, max_length=200, null=True), - ), - migrations.AddField( - model_name='macro_prepare', - name='gridsize', - field=models.CharField(blank=True, max_length=200, null=True), - ), - ] diff --git a/fiocruz/migrations/0018_macro_prepare_processo_name.py b/fiocruz/migrations/0018_macro_prepare_processo_name.py deleted file mode 100644 index 71cee8c..0000000 --- a/fiocruz/migrations/0018_macro_prepare_processo_name.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2023-11-07 06:27 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0017_macromoleculas_sem_redocking_delete_testes_and_more'), - ] - - operations = [ - migrations.AddField( - model_name='macro_prepare', - name='processo_name', - field=models.CharField(max_length=200, null=True), - ), - ] diff --git a/fiocruz/migrations/0019_alter_macro_prepare_ligantepdb_and_more.py b/fiocruz/migrations/0019_alter_macro_prepare_ligantepdb_and_more.py deleted file mode 100644 index f2bf5a1..0000000 --- a/fiocruz/migrations/0019_alter_macro_prepare_ligantepdb_and_more.py +++ /dev/null @@ -1,24 +0,0 @@ -# Generated by Django 4.2.4 on 2023-12-12 16:05 - -from django.db import migrations, models -import fiocruz.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0018_macro_prepare_processo_name'), - ] - - operations = [ - migrations.AlterField( - model_name='macro_prepare', - name='ligantepdb', - field=models.FileField(null=True, upload_to=fiocruz.models.arquivo), - ), - migrations.AlterField( - model_name='macro_prepare', - name='recptorpdbqt', - field=models.FileField(null=True, upload_to=fiocruz.models.arquivo), - ), - ] diff --git a/fiocruz/migrations/0020_usercustom_created_at_usercustom_updated_at_and_more.py b/fiocruz/migrations/0020_usercustom_created_at_usercustom_updated_at_and_more.py deleted file mode 100644 index 4d1836f..0000000 --- a/fiocruz/migrations/0020_usercustom_created_at_usercustom_updated_at_and_more.py +++ /dev/null @@ -1,37 +0,0 @@ -# Generated by Django 4.2.4 on 2024-01-29 08:43 - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - dependencies = [ - ("fiocruz", "0019_alter_macro_prepare_ligantepdb_and_more"), - ] - - operations = [ - migrations.AddField( - model_name="usercustom", - name="created_at", - field=models.DateTimeField(default=django.utils.timezone.now), - ), - migrations.AddField( - model_name="usercustom", - name="updated_at", - field=models.DateTimeField(auto_now=True), - ), - migrations.AlterField( - model_name="usercustom", - name="deleted", - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name="usercustom", - name="role", - field=models.CharField( - choices=[("USER", "User"), ("ADMIN", "Admin")], - default="USER", - max_length=255, - ), - ), - ] diff --git a/fiocruz/migrations/0021_alter_usercustom_created_at.py b/fiocruz/migrations/0021_alter_usercustom_created_at.py deleted file mode 100644 index cdae284..0000000 --- a/fiocruz/migrations/0021_alter_usercustom_created_at.py +++ /dev/null @@ -1,17 +0,0 @@ -# Generated by Django 4.2.4 on 2024-01-29 08:44 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("fiocruz", "0020_usercustom_created_at_usercustom_updated_at_and_more"), - ] - - operations = [ - migrations.AlterField( - model_name="usercustom", - name="created_at", - field=models.DateTimeField(auto_now_add=True), - ), - ] diff --git a/fiocruz/migrations/0022_arquivos_virtauls_redocking_and_more.py b/fiocruz/migrations/0022_arquivos_virtauls_redocking_and_more.py deleted file mode 100644 index 4e851e1..0000000 --- a/fiocruz/migrations/0022_arquivos_virtauls_redocking_and_more.py +++ /dev/null @@ -1,44 +0,0 @@ -# Generated by Django 4.2.4 on 2024-03-08 23:20 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("fiocruz", "0021_alter_usercustom_created_at"), - ] - - operations = [ - migrations.AddField( - model_name="arquivos_virtauls", - name="redocking", - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name="arquivos_virtauls", - name="status", - field=models.CharField( - choices=[ - ("em fila", "Em fila"), - ("processando", "Processando"), - ("concluido", "Concluído"), - ("error", "Erro"), - ], - default="em fila", - max_length=20, - ), - ), - migrations.AlterField( - model_name="arquivos_virtauls", - name="type", - field=models.CharField( - choices=[("vivax", "Vivax"), ("falciparum", "Falciparum")], - default="vivax", - max_length=10, - ), - ), - migrations.AlterModelTable( - name="arquivos_virtauls", - table="arquivos_virtauls", - ), - ] diff --git a/fiocruz/migrations/0023_remove_arquivos_virtauls_redocking_and_more.py b/fiocruz/migrations/0023_remove_arquivos_virtauls_redocking_and_more.py deleted file mode 100644 index 8db850c..0000000 --- a/fiocruz/migrations/0023_remove_arquivos_virtauls_redocking_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 4.2.4 on 2024-03-11 19:37 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0022_arquivos_virtauls_redocking_and_more'), - ] - - operations = [ - migrations.RemoveField( - model_name='arquivos_virtauls', - name='redocking', - ), - migrations.AlterField( - model_name='arquivos_virtauls', - name='status', - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name='arquivos_virtauls', - name='type', - field=models.TextField(default='Com Redocking'), - ), - migrations.AlterModelTable( - name='arquivos_virtauls', - table='Arquivos_virtaulS', - ), - ] diff --git a/fiocruz/migrations/0024_process_plasmodocking_delete_arquivos_virtauls.py b/fiocruz/migrations/0024_process_plasmodocking_delete_arquivos_virtauls.py deleted file mode 100644 index 55d04f6..0000000 --- a/fiocruz/migrations/0024_process_plasmodocking_delete_arquivos_virtauls.py +++ /dev/null @@ -1,35 +0,0 @@ -# Generated by Django 4.2.4 on 2024-03-13 18:03 - -from django.db import migrations, models -import django.db.models.deletion -import fiocruz.models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0023_remove_arquivos_virtauls_redocking_and_more'), - ] - - operations = [ - migrations.CreateModel( - name='Process_Plasmodocking', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nome', models.CharField(max_length=200)), - ('ligante', models.FileField(blank=True, null=True, upload_to=fiocruz.models.ligante_arquivo)), - ('data', models.DateTimeField(auto_now_add=True)), - ('resultado_final', models.TextField(default='Sem resultados')), - ('status', models.CharField(choices=[('em fila', 'Em fila'), ('processando', 'Processando'), ('concluido', 'Concluído'), ('error', 'Erro')], default='em fila', max_length=20)), - ('type', models.CharField(choices=[('vivax', 'Vivax'), ('falciparum', 'Falciparum')], default='Falciparum', max_length=10)), - ('redocking', models.BooleanField(default=True)), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fiocruz.usercustom')), - ], - options={ - 'db_table': 'process_plasmodocking', - }, - ), - migrations.DeleteModel( - name='Arquivos_virtaulS', - ), - ] diff --git a/fiocruz/migrations/0025_alter_process_plasmodocking_type.py b/fiocruz/migrations/0025_alter_process_plasmodocking_type.py deleted file mode 100644 index 1d68fe4..0000000 --- a/fiocruz/migrations/0025_alter_process_plasmodocking_type.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.2.4 on 2024-03-14 19:15 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('fiocruz', '0024_process_plasmodocking_delete_arquivos_virtauls'), - ] - - operations = [ - migrations.AlterField( - model_name='process_plasmodocking', - name='type', - field=models.CharField(choices=[('vivax', 'Vivax'), ('falciparum', 'Falciparum')], default='Falciparum', max_length=20), - ), - ] diff --git a/fiocruz/migrations/0026_macromoleculas_vivax_cr.py b/fiocruz/migrations/0026_macromoleculas_vivax_cr.py deleted file mode 100644 index d844e2b..0000000 --- a/fiocruz/migrations/0026_macromoleculas_vivax_cr.py +++ /dev/null @@ -1,44 +0,0 @@ -# Generated by Django 4.2.4 on 2024-04-29 18:15 - -from django.db import migrations, models -import fiocruz.models - - -class Migration(migrations.Migration): - dependencies = [ - ("fiocruz", "0025_alter_process_plasmodocking_type"), - ] - - operations = [ - migrations.CreateModel( - name="Macromoleculas_Vivax_CR", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("nome", models.CharField(max_length=200)), - ("rec", models.CharField(max_length=200)), - ("rec_fld", models.FileField(upload_to=fiocruz.models.arquivo_macro)), - ( - "ligante_original", - models.CharField(blank=True, max_length=200, null=True), - ), - ( - "rmsd_redoking", - models.CharField(blank=True, max_length=200, null=True), - ), - ( - "energia_orinal", - models.CharField(blank=True, max_length=200, null=True), - ), - ("gridsize", models.CharField(blank=True, max_length=200, null=True)), - ("gridcenter", models.CharField(blank=True, max_length=200, null=True)), - ], - ), - ] diff --git a/fiocruz/migrations/__pycache__/0001_initial.cpython-39.pyc b/fiocruz/migrations/__pycache__/0001_initial.cpython-39.pyc index cf7e5d9..26536b4 100644 Binary files a/fiocruz/migrations/__pycache__/0001_initial.cpython-39.pyc and b/fiocruz/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/fiocruz/migrations/__pycache__/0002_alter_macroprepare_table.cpython-39.pyc b/fiocruz/migrations/__pycache__/0002_alter_macroprepare_table.cpython-39.pyc new file mode 100644 index 0000000..36bac21 Binary files /dev/null and b/fiocruz/migrations/__pycache__/0002_alter_macroprepare_table.cpython-39.pyc differ diff --git a/fiocruz/migrations/__pycache__/0002_auto_20241007_0038.cpython-39.pyc b/fiocruz/migrations/__pycache__/0002_auto_20241007_0038.cpython-39.pyc new file mode 100644 index 0000000..89c77bd Binary files /dev/null and b/fiocruz/migrations/__pycache__/0002_auto_20241007_0038.cpython-39.pyc differ diff --git a/fiocruz/models.py b/fiocruz/models.py index 05c1dfa..533c834 100755 --- a/fiocruz/models.py +++ b/fiocruz/models.py @@ -1,17 +1,12 @@ import uuid from django.db import models -from django.contrib.auth.models import User -from django.urls import reverse -from datetime import datetime from django.contrib.auth.hashers import make_password, check_password from django.utils.translation import gettext_lazy as _ -# Create your models here. from django.utils import timezone - - +# Modelo customizado de usuário class UserCustom(models.Model): - id = models.TextField(primary_key=True, default=uuid.uuid4, editable=False) + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) # Alterado para UUIDField para consistência de IDs únicos email = models.EmailField(unique=True) name = models.CharField(max_length=255) password = models.CharField(max_length=255) @@ -19,12 +14,12 @@ class UserCustom(models.Model): active = models.BooleanField(default=False) deleted = models.BooleanField(default=False) role = models.CharField( - max_length=255, + max_length=255, default="USER", - choices=[('USER', 'User'), ('ADMIN', 'Admin')] # Exemplo de escolhas restritas + choices=[('USER', 'User'), ('ADMIN', 'Admin')] # Exemplo de escolhas restritas ) - created_at = models.DateTimeField(auto_now_add=True) # Data de criação - updated_at = models.DateTimeField(auto_now=True) # Data de última modificação + created_at = models.DateTimeField(auto_now_add=True) # Data de criação + updated_at = models.DateTimeField(auto_now=True) # Data de última modificação def __str__(self): return self.username @@ -37,14 +32,13 @@ def check_password(self, raw_password): class Meta: db_table = 'users' # Nome da tabela - -#-------------------------------------------------------------------------------------------- - + +# -------------------------------------------------------------------------------------------- def ligante_arquivo(instance, filename): - return 'plasmodocking/user_{0}/{1}/{2}/{3}'.format(instance.user.username, instance.nome,"pdb_split", filename) + return f'plasmodocking/user_{instance.user.username}/{instance.nome}/pdb_split/{filename}' -class Process_Plasmodocking(models.Model): +class ProcessPlasmodocking(models.Model): TYPE_CHOICES = [ ("vivax", "Vivax"), ("falciparum", "Falciparum"), @@ -61,7 +55,7 @@ class Process_Plasmodocking(models.Model): data = models.DateTimeField(auto_now_add=True) resultado_final = models.TextField(default='Sem resultados') status = models.CharField(max_length=20, choices=STATUS_CHOICES, default="em fila") - type = models.CharField(max_length=20, choices=TYPE_CHOICES, default="Falciparum") + type = models.CharField(max_length=20, choices=TYPE_CHOICES, default="falciparum") redocking = models.BooleanField(default=True) def __str__(self): @@ -70,70 +64,76 @@ def __str__(self): class Meta: db_table = 'process_plasmodocking' -#Macromoleculas Com Redocking -def arquivo_macro(instance, filename): - return 'macromoleculas/comRedocking/{0}/{1}'.format(instance.rec, filename) +# -------------------------------------------------------------------------------------------- -class Macromoleculas_virtaulS(models.Model): +# Função dinâmica para upload de macromoléculas +def macromolecule_upload_path(instance, filename): + type_directory = "falciparum" if "Falciparum" in instance._meta.verbose_name else "vivax" + redocking_directory = "withRedocking" if instance.redocking else "withoutRedocking" + return f'macromoleculas/{type_directory}/{redocking_directory}/{instance.rec}/{filename}' + +# Classe base para Macromoléculas +class Macromolecule(models.Model): nome = models.CharField(max_length=200) rec = models.CharField(max_length=200) - rec_fld = models.FileField(upload_to=arquivo_macro) + rec_fld = models.FileField(upload_to=macromolecule_upload_path) - ligante_original = models.CharField(max_length=200,blank=True, null=True) - rmsd_redoking = models.CharField(max_length=200,blank=True, null=True) - energia_orinal = models.CharField(max_length=200,blank=True, null=True) - gridsize = models.CharField(max_length=200,blank=True, null=True) - gridcenter = models.CharField(max_length=200,blank=True, null=True) + gridsize = models.CharField(max_length=200, blank=True, null=True) + gridcenter = models.CharField(max_length=200, blank=True, null=True) - def __str__(self): - return self.nome + ligante_original = models.CharField(max_length=200, blank=True, null=True) + rmsd_redocking = models.CharField(max_length=200, blank=True, null=True) + energia_original = models.CharField(max_length=200, blank=True, null=True) -#Macromoleculas Sem redocking -def arquivo_macro_SR(instance, filename): - return 'macromoleculas/semRedocking/{0}/{1}'.format(instance.rec, filename) + def __str__(self): + return self.nome -class Macromoleculas_Sem_Redocking(models.Model): - nome = models.CharField(max_length=200) - rec = models.CharField(max_length=200) - rec_fld = models.FileField(upload_to=arquivo_macro_SR) + class Meta: + abstract = True - gridsize = models.CharField(max_length=200,blank=True, null=True) - gridcenter = models.CharField(max_length=200,blank=True, null=True) +# Macromoléculas Falciparum com redocking +class MacromoleculesFalciparumWithRedocking(Macromolecule): + redocking = models.BooleanField(default=True) - def __str__(self): - return self.nome class Meta: - db_table = 'Macromoleculas_Sem_Redocking' + db_table = 'macromolecules_falciparum_with_redocking' -def arquivo(instance, filename): - return 'macroTeste/{0}/{1}/{2}'.format(instance.processo_name,instance.rec, filename) +# Macromoléculas Falciparum sem redocking +class MacromoleculesFalciparumWithoutRedocking(Macromolecule): + ligante_original = None # Não necessário para este modelo + rmsd_redocking = None # Não necessário para este modelo + energia_original = None # Não necessário para este modelo + redocking = models.BooleanField(default=False) -class Macro_Prepare(models.Model): - processo_name = models.CharField(max_length=200, null=True) - nome = models.CharField(max_length=200) - rec = models.CharField(max_length=200) + class Meta: + db_table = 'macromolecules_falciparum_without_redocking' + +# Macromoléculas Vivax com redocking +class MacromoleculesVivaxWithRedocking(Macromolecule): + redocking = models.BooleanField(default=True) - recptorpdb = models.FileField(upload_to=arquivo) - recptorpdbqt = models.FileField(upload_to=arquivo, null=True) - ligantepdb = models.FileField(upload_to=arquivo, null=True) + class Meta: + db_table = 'macromolecules_vivax_with_redocking' - gridsize = models.CharField(max_length=200,blank=True, null=True) - gridcenter = models.CharField(max_length=200,blank=True, null=True) +# -------------------------------------------------------------------------------------------- - def __str__(self): - return self.nome +def arquivo(instance, filename): + return f'macroTeste/{instance.processo_name}/{instance.rec}/{filename}' -#Vivax Macromoleculas -class Macromoleculas_Vivax_CR(models.Model): +class MacroPrepare(models.Model): + processo_name = models.CharField(max_length=200, null=True) nome = models.CharField(max_length=200) rec = models.CharField(max_length=200) - rec_fld = models.FileField(upload_to=arquivo_macro) - ligante_original = models.CharField(max_length=200,blank=True, null=True) - rmsd_redoking = models.CharField(max_length=200,blank=True, null=True) - energia_orinal = models.CharField(max_length=200,blank=True, null=True) - gridsize = models.CharField(max_length=200,blank=True, null=True) - gridcenter = models.CharField(max_length=200,blank=True, null=True) + receptor_pdb = models.FileField(upload_to=arquivo) + receptor_pdbqt = models.FileField(upload_to=arquivo, null=True) + ligante_pdb = models.FileField(upload_to=arquivo, null=True) + + gridsize = models.CharField(max_length=200, blank=True, null=True) + gridcenter = models.CharField(max_length=200, blank=True, null=True) def __str__(self): - return self.nome \ No newline at end of file + return self.nome + + class Meta: + db_table = 'macro_prepare' diff --git a/fiocruz/serializers.py b/fiocruz/serializers.py index 620770b..bb722c8 100755 --- a/fiocruz/serializers.py +++ b/fiocruz/serializers.py @@ -3,14 +3,14 @@ from rest_framework import routers, serializers, viewsets from django.contrib.auth.models import User -from .models import Process_Plasmodocking, UserCustom +from .models import ProcessPlasmodocking, UserCustom class VS_Serializer(serializers.ModelSerializer): # Adicione um campo de método para a data formatada formatted_data = serializers.SerializerMethodField() class Meta: - model = Process_Plasmodocking + model = ProcessPlasmodocking fields = ['id', 'nome', 'user', 'ligante', 'data', 'redocking', 'status','type', 'formatted_data','resultado_final'] def get_formatted_data(self, obj): @@ -38,5 +38,5 @@ class ProcessPlasmodockingSerializer(serializers.ModelSerializer): username = serializers.CharField(write_only=True) class Meta: - model = Process_Plasmodocking + model = ProcessPlasmodocking fields = '__all__' \ No newline at end of file diff --git a/fiocruz/tasks.py b/fiocruz/tasks.py index e4dc505..8b8d7b2 100755 --- a/fiocruz/tasks.py +++ b/fiocruz/tasks.py @@ -6,7 +6,8 @@ from tqdm import tqdm from celery import shared_task from django.conf import settings -from fiocruz.models import Process_Plasmodocking, Macromoleculas_virtaulS, Macro_Prepare, Macromoleculas_Sem_Redocking, Macromoleculas_Vivax_CR +from .models import ProcessPlasmodocking, MacromoleculesFalciparumWithRedocking, UserCustom, MacroPrepare, MacromoleculesFalciparumWithoutRedocking +from fiocruz.models import ProcessPlasmodocking, MacromoleculesFalciparumWithRedocking, MacroPrepare, MacromoleculesFalciparumWithoutRedocking, MacromoleculesVivaxWithRedocking from django.core.mail import send_mail from django.template.loader import render_to_string @@ -37,7 +38,7 @@ run_autodock as run_autodock_CR, ) -from .utils.macro_prepare_semRedocking import ( +from .utils.macro_prepare_comRedocking import ( preparacao_gpf as preparacao_gpf_SR, run_autogrid as run_autogrid_SR, modifcar_fld as modifcar_fld_SR, @@ -50,7 +51,7 @@ def add(x, y): #Processo principal plamodocking sem redocking @shared_task def plasmodocking_SR(username, id_processo, email_user): - arquivos_vs = Process_Plasmodocking.objects.get(id=id_processo) + arquivos_vs = ProcessPlasmodocking.objects.get(id=id_processo) arquivos_vs.status = "processando" arquivos_vs.save() @@ -67,11 +68,11 @@ def plasmodocking_SR(username, id_processo, email_user): #--------------------------------------------------------------------- #execução do AutodockGPU if arquivos_vs.type == 'falciparum' : - macromoleculas = Macromoleculas_virtaulS.objects.all() + macromoleculas = MacromoleculesFalciparumWithRedocking.objects.all() print("Macromoleculas Falciparum sem redocking") else: - macromoleculas = Macromoleculas_virtaulS.objects.all() + macromoleculas = MacromoleculesFalciparumWithRedocking.objects.all() print("Macromoleculas Vivax sem redocking") @@ -120,55 +121,65 @@ def plasmodocking_SR(username, id_processo, email_user): #Processo principal plamodocking com redocking @shared_task def plasmodocking_CR(username, id_processo, email_user): - arquivos_vs = Process_Plasmodocking.objects.get(id=id_processo) - arquivos_vs.status = "processando" - arquivos_vs.save() - #--------------------------------------------------------------------- - # criar pastas do usuario - dir_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}", arquivos_vs.nome) - diretorio_macromoleculas,diretorio_dlgs,diretorio_gbests,diretorio_lig_split,diretorio_ligantes_pdbqt = criar_diretorios(username, arquivos_vs.nome) - #--------------------------------------------------------------------- - #preparação ligante - preparar_ligantes(arquivos_vs,diretorio_lig_split,diretorio_ligantes_pdbqt) - ligantes_pdbqt = listar_arquivos(diretorio_ligantes_pdbqt) - #--------------------------------------------------------------------- - #execução do AutodockGPU - if arquivos_vs.type == 'falciparum' : - macromoleculas = Macromoleculas_virtaulS.objects.all() - print("Macromoleculas Falciparum com redocking") - else: - macromoleculas = Macromoleculas_Vivax_CR.objects.all() - print("Macromoleculas Vivax com redocking") - data, tabela_final = [], [] - with tqdm(total=len(macromoleculas), desc=f'Plasmodocking usuario {username} processo {arquivos_vs.nome}') as pbar: - for macromolecula in macromoleculas: - print("Macromolecula: "+macromolecula.rec) - receptor_data, data_data = preparar_dados_receptor(macromolecula, ligantes_pdbqt, diretorio_dlgs,diretorio_ligantes_pdbqt, - diretorio_macromoleculas,username,arquivos_vs.nome,arquivos_vs.type) - data.append(receptor_data) - tabela_final.extend(data_data) - # Atualize a barra de progresso - pbar.update(1) - #fim dos 2 for ligante e receptor - remover_arquivos_xml(diretorio_dlgs, "*.xml") - json_data = json.dumps(data, indent=4) - # Especifique o caminho e nome do arquivo onde você deseja salvar o JSON - file_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}", arquivos_vs.nome,"dados.json") - with open(file_path, 'w') as json_file: - json_file.write(json_data) - arquivos_vs.status = "concluido" - arquivos_vs.resultado_final = json_data - arquivos_vs.save() - file_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}", arquivos_vs.nome) - dfdf = pd.DataFrame(tabela_final) - csv_file_path = os.path.join(file_path, 'dadostab.csv') - dfdf.to_csv(csv_file_path, sep=';', index=False) - #----------------zip file--------------- - dir_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}") - command = ["zip", "-r", arquivos_vs.nome+"/"+arquivos_vs.nome+".zip", arquivos_vs.nome] - executar_comando(command, dir_path) - ##enviar_email.delay(username,arquivos_vs.nome,email_user) - return "task concluida com sucesso" + try: + arquivos_vs = ProcessPlasmodocking.objects.get(id=id_processo) + arquivos_vs.status = "processando" + arquivos_vs.save() + #--------------------------------------------------------------------- + # criar pastas do usuario + dir_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}", arquivos_vs.nome) + diretorio_macromoleculas,diretorio_dlgs,diretorio_gbests,diretorio_lig_split,diretorio_ligantes_pdbqt = criar_diretorios(username, arquivos_vs.nome) + #--------------------------------------------------------------------- + #preparação ligante + preparar_ligantes(arquivos_vs,diretorio_lig_split,diretorio_ligantes_pdbqt) + ligantes_pdbqt = listar_arquivos(diretorio_ligantes_pdbqt) + #--------------------------------------------------------------------- + #execução do AutodockGPU + + if arquivos_vs.type == 'falciparum' : + macromoleculas = MacromoleculesFalciparumWithRedocking.objects.all() + print("Macromoleculas Falciparum com redocking") + else: + macromoleculas = MacromoleculesVivaxWithRedocking.objects.all() + print("Macromoleculas Vivax com redocking") + data, tabela_final = [], [] + with tqdm(total=len(macromoleculas), desc=f'Plasmodocking usuario {username} processo {arquivos_vs.nome}') as pbar: + for macromolecula in macromoleculas: + print("Macromolecula: "+macromolecula.rec) + print("Macromolecula energia original: "+macromolecula.energia_original) + receptor_data, data_data = preparar_dados_receptor(macromolecula, ligantes_pdbqt, diretorio_dlgs,diretorio_ligantes_pdbqt, + diretorio_macromoleculas,username,arquivos_vs.nome,arquivos_vs.type) + data.append(receptor_data) + tabela_final.extend(data_data) + # Atualize a barra de progresso + pbar.update(1) + #fim dos 2 for ligante e receptor + remover_arquivos_xml(diretorio_dlgs, "*.xml") + json_data = json.dumps(data, indent=4) + # Especifique o caminho e nome do arquivo onde você deseja salvar o JSON + file_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}", arquivos_vs.nome,"dados.json") + with open(file_path, 'w') as json_file: + json_file.write(json_data) + arquivos_vs.status = "concluido" + arquivos_vs.resultado_final = json_data + arquivos_vs.save() + file_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}", arquivos_vs.nome) + dfdf = pd.DataFrame(tabela_final) + csv_file_path = os.path.join(file_path, 'dadostab.csv') + dfdf.to_csv(csv_file_path, sep=';', index=False) + #----------------zip file--------------- + dir_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{username}") + command = ["zip", "-r", arquivos_vs.nome+"/"+arquivos_vs.nome+".zip", arquivos_vs.nome] + executar_comando(command, dir_path) + ##enviar_email.delay(username,arquivos_vs.nome,email_user) + return "task concluida com sucesso" + + except Exception as e: + # Em caso de erro, atualizar o status para "error" + arquivos_vs.status = "error" + arquivos_vs.save() + print(f"Ocorreu um erro no processo: {str(e)}") + return f"task falhou: {str(e)}" #Processo de envio de email @shared_task @@ -195,7 +206,7 @@ def enviar_email(usename,processo,email_user): @shared_task def prepare_macro_SemRedocking(id_processo): - macroPrepare = Macro_Prepare.objects.get(id=id_processo) + macroPrepare = MacroPrepare.objects.get(id=id_processo) print("ok 1") @@ -211,7 +222,7 @@ def prepare_macro_SemRedocking(id_processo): @shared_task def prepare_macro_ComRedocking(id_processo): - macroPrepare = Macro_Prepare.objects.get(id=id_processo) + macroPrepare = MacroPrepare.objects.get(id=id_processo) pythonsh_path = os.path.expanduser("/home/autodockgpu/mgltools_x86_64Linux2_1.5.7/bin/pythonsh") prep_gpf_path = os.path.expanduser("/home/autodockgpu/mgltools_x86_64Linux2_1.5.7/MGLToolsPckgs/AutoDockTools/Utilities24/prepare_gpf4.py") diff --git a/fiocruz/utils/__pycache__/functions.cpython-39.pyc b/fiocruz/utils/__pycache__/functions.cpython-39.pyc index 5eb10d5..be411d3 100644 Binary files a/fiocruz/utils/__pycache__/functions.cpython-39.pyc and b/fiocruz/utils/__pycache__/functions.cpython-39.pyc differ diff --git a/fiocruz/utils/__pycache__/plasmodocking_run.cpython-39.pyc b/fiocruz/utils/__pycache__/plasmodocking_run.cpython-39.pyc index fd29357..ff7ffa7 100644 Binary files a/fiocruz/utils/__pycache__/plasmodocking_run.cpython-39.pyc and b/fiocruz/utils/__pycache__/plasmodocking_run.cpython-39.pyc differ diff --git a/fiocruz/utils/functions.py b/fiocruz/utils/functions.py index 52b00a0..9edfd44 100755 --- a/fiocruz/utils/functions.py +++ b/fiocruz/utils/functions.py @@ -2,7 +2,6 @@ import os import shutil import subprocess -from ..models import Process_Plasmodocking, Macromoleculas_virtaulS, UserCustom, Macro_Prepare from rest_framework import routers, serializers, viewsets from django.http import FileResponse, HttpResponse, JsonResponse from django.contrib.auth.models import User diff --git a/fiocruz/utils/plasmodocking_run.py b/fiocruz/utils/plasmodocking_run.py index 0f09c4c..a9bc036 100755 --- a/fiocruz/utils/plasmodocking_run.py +++ b/fiocruz/utils/plasmodocking_run.py @@ -72,16 +72,19 @@ def preparar_dados_receptor(macromolecula, ligantes_pdbqt, diretorio_dlgs,direto receptor_data = { 'receptor_name': macromolecula.rec, + 'molecule_name': macromolecula.nome, 'ligante_original': macromolecula.ligante_original, 'grid_center': macromolecula.gridcenter, 'grid_size': macromolecula.gridsize, - 'energia_original': macromolecula.energia_orinal, - 'rmsd_redocking': macromolecula.rmsd_redoking, + 'energia_original': macromolecula.energia_original, + 'rmsd_redocking': macromolecula.rmsd_redocking, 'ligantes': [] } + print(" Nome molecula: " + macromolecula.nome) + data_data = [] - + for ligante_pdbqt in ligantes_pdbqt: dir_ligante_pdbqt = os.path.join(diretorio_ligantes_pdbqt, ligante_pdbqt) print(ligante_pdbqt+" : " + macromolecula.rec) @@ -143,7 +146,7 @@ def preparar_dados_receptor(macromolecula, ligantes_pdbqt, diretorio_dlgs,direto data_data.append({ 'RECEPTOR_NAME': macromolecula.rec, 'LIGANTE_REDOCKING': macromolecula.ligante_original, - 'ENERGIA_REDOCKING': macromolecula.energia_orinal, + 'ENERGIA_REDOCKING': macromolecula.energia_original, 'LIGANTE_CID': filename_ligante, 'LIGANTE_MELHOR_ENERGIA': best_energia, 'RUN': run, diff --git a/fiocruz/views.py b/fiocruz/views.py index 90dcb80..3db5a2c 100755 --- a/fiocruz/views.py +++ b/fiocruz/views.py @@ -4,7 +4,7 @@ import subprocess import random from fiocruz.utils.functions import extrair_menor_rmsd -from .models import Process_Plasmodocking, Macromoleculas_virtaulS, UserCustom, Macro_Prepare, Macromoleculas_Sem_Redocking +from .models import ProcessPlasmodocking, MacromoleculesFalciparumWithRedocking, UserCustom, MacroPrepare, MacromoleculesFalciparumWithoutRedocking from rest_framework import viewsets, generics from django.http import FileResponse, HttpResponse, JsonResponse from .serializers import ProcessPlasmodockingSerializer, VS_Serializer, UserCustomSerializer @@ -16,6 +16,7 @@ from rest_framework import status from django.shortcuts import render from rest_framework.decorators import action +from rest_framework.parsers import MultiPartParser, FormParser from .util import ( textfld, ) @@ -60,32 +61,18 @@ def get(self, request): if user: return Response(UserCustomSerializer(user).data) else: - return Response({'error': 'User not found'}, status=status.HTTP_404_NOT_FOUND) - -#----------------------------------------------------------------------------------------------------------------- -class VS_ViewSet(viewsets.ModelViewSet): - #queryset = Process_Plasmodocking.objects.all() - #queryset = Process_Plasmodocking.objects.filter(status=False) # Filtrar por status igual a false - serializer_class = VS_Serializer - - - def get_queryset(self): - username = self.request.query_params.get('username') - user = UserCustom.objects.get(username=username) - queryset = Process_Plasmodocking.objects.filter(user=user) - return queryset - + return Response({'error': 'User not found'}, status=status.HTTP_404_NOT_FOUND) def get_resultado(request, idItem): if request.method == 'GET': try: - arq = Process_Plasmodocking.objects.get(id=idItem) + arq = ProcessPlasmodocking.objects.get(id=idItem) # Use o serializer para serializar o objeto serializer = VS_Serializer(arq) return JsonResponse({'dados': serializer.data}) - except Process_Plasmodocking.DoesNotExist: + except ProcessPlasmodocking.DoesNotExist: return JsonResponse({'message': 'Item não encontrado'}, status=404) else: return JsonResponse({'message': 'Método não permitido'}, status=405) @@ -93,7 +80,7 @@ def get_resultado(request, idItem): def api_delete(request, idItem): if request.method == 'DELETE': try: - arq = Process_Plasmodocking.objects.get(id=idItem) + arq = ProcessPlasmodocking.objects.get(id=idItem) arq.delete() dir_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{arq.user.username}", arq.nome) @@ -105,15 +92,15 @@ def api_delete(request, idItem): return JsonResponse(f"Ocorreu um erro ao excluir o diretório: {e.stderr}") return JsonResponse({'message': 'Arquivo apagado com sucesso!'}) - except Process_Plasmodocking.DoesNotExist: + except ProcessPlasmodocking.DoesNotExist: return JsonResponse({'message': 'Item não encontrado'}, status=404) else: return JsonResponse({'message': 'Método não permitido'}, status=405) def download_file(request, id): - # Recupere o objeto Process_Plasmodocking com base no ID - file = Process_Plasmodocking.objects.get(id=id) + # Recupere o objeto ProcessPlasmodocking com base no ID + file = ProcessPlasmodocking.objects.get(id=id) dir_path = os.path.join(settings.MEDIA_ROOT, "plasmodocking", f"user_{file.user.username}", file.nome) zip_path = os.path.join(dir_path, f"{file.nome}.zip") @@ -129,13 +116,13 @@ def download_file(request, id): def generate_unique_id(): while True: new_id = random.randint(1, 1000000) # Escolha o intervalo apropriado para os IDs - if not Macromoleculas_virtaulS.objects.filter(id=new_id).exists(): + if not MacromoleculesFalciparumWithRedocking.objects.filter(id=new_id).exists(): return new_id def generate_unique_id_SR(): while True: new_id = random.randint(1, 1000000) # Escolha o intervalo apropriado para os IDs - if not Macromoleculas_Sem_Redocking.objects.filter(id=new_id).exists(): + if not MacromoleculesFalciparumWithoutRedocking.objects.filter(id=new_id).exists(): return new_id def macro_save_ComRedocking(request): @@ -155,7 +142,7 @@ def macro_save_ComRedocking(request): dir = os.path.join("macromoleculas", "comRedocking", rec, fld_name) unique_id = generate_unique_id() - macromolecula = Macromoleculas_virtaulS(id=unique_id,nome=nome, rec=rec, gridcenter=gridcenter, + macromolecula = MacromoleculesFalciparumWithRedocking(id=unique_id,nome=nome, rec=rec, gridcenter=gridcenter, gridsize=gridsize, rmsd_redoking=rmsd_redocking, energia_orinal=energia_redocking, ligante_original=ligante_redocking, rec_fld=dir) @@ -183,7 +170,7 @@ def macro_save_SemRedocking(request): dir = os.path.join("macromoleculas", "semRedocking", rec, fld_name) unique_id = generate_unique_id_SR() - macromolecula = Macromoleculas_Sem_Redocking(id=unique_id,nome=nome, rec=rec, gridcenter=gridcenter, + macromolecula = MacromoleculesFalciparumWithoutRedocking(id=unique_id,nome=nome, rec=rec, gridcenter=gridcenter, gridsize=gridsize, rec_fld=dir) macromolecula.save() @@ -207,7 +194,7 @@ def macro(request): receptorpdbqt = request.FILES.get('receptorpdbqt') ligantepdb = request.FILES.get('ligantepdb') - macroteste = Macro_Prepare(processo_name=processo_name, nome=nome,rec=rec,gridsize=gridsize,gridcenter=gridcenter, + macroteste = MacroPrepare(processo_name=processo_name, nome=nome,rec=rec,gridsize=gridsize,gridcenter=gridcenter, recptorpdb= receptorpdb, recptorpdbqt= receptorpdbqt, ligantepdb= ligantepdb) macroteste.save() @@ -220,7 +207,6 @@ def macro(request): return JsonResponse({'message': 'Método não suportado'}, status=405) - def macro_SR(request): if request.method == 'POST': processo_name = request.POST.get('processo_name') @@ -232,7 +218,7 @@ def macro_SR(request): receptorpdb = request.FILES.get('receptorpdb') - macroteste = Macro_Prepare(processo_name=processo_name, nome=nome,rec=rec,gridsize=gridsize,gridcenter=gridcenter, + macroteste = MacroPrepare(processo_name=processo_name, nome=nome,rec=rec,gridsize=gridsize,gridcenter=gridcenter, recptorpdb= receptorpdb) macroteste.save() @@ -246,48 +232,7 @@ def macro_SR(request): return JsonResponse({'message': 'Método não suportado'}, status=405) -#------------------------------------------------------------------------ -def upload_view(request): - if request.method == 'POST': - - nome = request.POST.get('nome') - arquivo = request.FILES.get('arquivo') - username = request.POST.get('username') - type = request.POST.get('type') # Assumindo que isso vem corretamente como "vivax" ou "falciparum" - redocking = request.POST.get('redocking') == 'true' # Isso captura se "redocking" foi marcado como 'true' - email_user = request.POST.get('email_user') - - try: - user = UserCustom.objects.get(username=username) - except UserCustom.DoesNotExist: - return JsonResponse({'message': 'Usuário não encontrado'}, status=404) - - if Process_Plasmodocking.objects.filter(user=user, nome=nome).exists(): - return JsonResponse({'message': 'Um arquivo com esse nome já existe para esse usuário'}, status=400) - - arquivos_vs = Process_Plasmodocking(nome=nome, ligante=arquivo, user=user, type=type, redocking=redocking, status="em fila") - arquivos_vs.save() - - #--------------------------------------------------------------------- - # Iniciando a task baseado no tipo de processamento e se redocking é True ou False - print(redocking) - print(type) - - # Inicia o processo de docking baseado no tipo e na necessidade de redocking - if type == 'falciparum' and redocking: - plasmodocking_CR.delay(username, arquivos_vs.id, email_user) - elif type == 'falciparum' and not redocking: - plasmodocking_SR.delay(username, arquivos_vs.id, email_user) - elif type == 'vivax' and redocking: - print("Vivax com redocking") - plasmodocking_CR.delay(username, arquivos_vs.id, email_user) - elif type == 'vivax' and not redocking: - print("Vivax sem redocking") - plasmodocking_SR.delay(username, arquivos_vs.id, email_user) - return JsonResponse({'message': 'Processo adicionado a fila com sucesso. em breve estará disponivel nos resultados.'}) - else: - return JsonResponse({'message': 'Método não suportado'}, status=405) def view3d(request, username, nome_process, receptor_name, ligante_code): @@ -325,54 +270,67 @@ def view3d(request, username, nome_process, receptor_name, ligante_code): class ProcessPlasmodockingViewSet(viewsets.ModelViewSet): - queryset = Process_Plasmodocking.objects.all() + queryset = ProcessPlasmodocking.objects.all() serializer_class = ProcessPlasmodockingSerializer + parser_classes = [MultiPartParser, FormParser] # Para aceitar arquivos multipart @action(detail=False, methods=['get'], url_path='by-user') def by_user(self, request): username = request.query_params.get('username', None) if username is not None: - user = UserCustom.objects.get(username=username) - queryset = Process_Plasmodocking.objects.filter(user=user) + try: + user = UserCustom.objects.get(username=username) + except UserCustom.DoesNotExist: + return Response({"message": "Usuário não encontrado"}, status=status.HTTP_404_NOT_FOUND) + queryset = ProcessPlasmodocking.objects.filter(user=user) serializer = self.get_serializer(queryset, many=True) return Response(serializer.data, status=status.HTTP_200_OK) else: return Response({"detail": "Parâmetro 'username' é necessário."}, status=status.HTTP_400_BAD_REQUEST) - + def create(self, request, *args, **kwargs): data = request.data username = data.get('username') nome = data.get('nome') - arquivo = data.get('ligante') - type = data.get('type') + arquivo = request.FILES.get('arquivo') + type = data.get('type') # Tipo: 'vivax' ou 'falciparum' redocking = data.get('redocking', True) # Será passado como booleano + email_user = data.get('email_user') - try: - redocking = bool(redocking) - except ValueError: - return Response({'message': 'Valor inválido para redocking.'}, status=status.HTTP_400_BAD_REQUEST) + # Converter redocking para booleano + redocking = True if redocking in ['true', 'True', True] else False + # Verificar se o usuário existe try: user = UserCustom.objects.get(username=username) except UserCustom.DoesNotExist: return Response({'message': 'Usuário não encontrado'}, status=status.HTTP_404_NOT_FOUND) - if Process_Plasmodocking.objects.filter(user=user, nome=nome).exists(): + # Verificar se já existe um processo com esse nome para o usuário + if ProcessPlasmodocking.objects.filter(user=user, nome=nome).exists(): return Response({'message': 'Um processo com esse nome já existe para este usuário'}, status=status.HTTP_400_BAD_REQUEST) - email_user = user.email - - arquivos_vs = Process_Plasmodocking(nome=nome, ligante=arquivo, user=user, type=type, redocking=redocking, status="em fila") + # Criar um novo processo + arquivos_vs = ProcessPlasmodocking( + nome=nome, + ligante=arquivo, + user=user, + type=type, + redocking=redocking, + status="em fila" + ) arquivos_vs.save() + # Iniciar o processo de docking dependendo do tipo e do redocking if type == 'falciparum' and redocking: - plasmodocking_CR.delay(username, arquivos_vs.id, email_user) + plasmodocking_CR.delay(username, arquivos_vs.id, user.email) elif type == 'falciparum' and not redocking: - plasmodocking_SR.delay(username, arquivos_vs.id, email_user) + plasmodocking_SR.delay(username, arquivos_vs.id, user.email) elif type == 'vivax' and redocking: - plasmodocking_CR.delay(username, arquivos_vs.id, email_user) + plasmodocking_CR.delay(username, arquivos_vs.id, user.email) elif type == 'vivax' and not redocking: - plasmodocking_SR.delay(username, arquivos_vs.id, email_user) + plasmodocking_SR.delay(username, arquivos_vs.id, user.email) + # Serializar e retornar a resposta serializer = self.get_serializer(arquivos_vs) - return Response(serializer.data, status=status.HTTP_201_CREATED) + return Response(serializer.data, status=status.HTTP_201_CREATED) \ No newline at end of file