-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from ProteinsWebTeam/dev
Last check before moving it to master
- Loading branch information
Showing
20 changed files
with
570 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 3.0.7 on 2021-01-11 13:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [("webfront", "0011_pfam2interpro")] | ||
|
||
operations = [ | ||
migrations.RemoveField(model_name="protein", name="extra_features"), | ||
migrations.RemoveField(model_name="protein", name="residues"), | ||
migrations.RemoveField(model_name="protein", name="sequence"), | ||
migrations.AddField( | ||
model_name="protein", | ||
name="sequence_bin", | ||
field=models.BinaryField(db_column="sequence", null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 3.0.7 on 2021-01-11 16:29 | ||
|
||
from django.db import migrations, models | ||
import jsonfield.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [("webfront", "0012_seq_and_seq_raw")] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ProteinExtraFeatures", | ||
fields=[ | ||
("feature_id", models.IntegerField(primary_key=True, serialize=False)), | ||
("protein_acc", models.CharField(max_length=15)), | ||
("entry_acc", models.CharField(max_length=25)), | ||
("source_database", models.CharField(max_length=10)), | ||
("location_start", models.IntegerField()), | ||
("location_end", models.IntegerField()), | ||
("sequence_feature", models.CharField(max_length=35)), | ||
], | ||
options={"db_table": "webfront_proteinfeature"}, | ||
), | ||
migrations.CreateModel( | ||
name="ProteinResidues", | ||
fields=[ | ||
("residue_id", models.IntegerField(primary_key=True, serialize=False)), | ||
("protein_acc", models.CharField(max_length=15)), | ||
("entry_acc", models.CharField(max_length=25)), | ||
("entry_name", models.CharField(max_length=100)), | ||
("source_database", models.CharField(max_length=10)), | ||
("description", models.CharField(max_length=255)), | ||
("fragments", jsonfield.fields.JSONField(null=True)), | ||
], | ||
options={"db_table": "webfront_proteinresidue"}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 3.0.7 on 2021-02-05 10:34 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [("webfront", "0013_protein_extra")] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="StructuralModel", | ||
fields=[ | ||
("model_id", models.IntegerField(primary_key=True, serialize=False)), | ||
("accession", models.CharField(max_length=25)), | ||
("contacts", models.BinaryField()), | ||
("structure", models.BinaryField()), | ||
], | ||
options={"db_table": "webfront_structuralmodel"}, | ||
) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Testing | ||
=== | ||
|
||
Generating fixtures for gzip BinaryFields | ||
--- | ||
This in an example of how to generate the fixtures file for `StructuralModel`. The same approach was used for the sequence in the `Protein` table. | ||
|
||
1. Go the djano shell. Make sure you are using the test DB by setting `use_test_db: true` in `interpro.local.yml`. | ||
```shell | ||
python3 manage.py shell | ||
``` | ||
|
||
2. Manually create the fixture, using `gzip` and `bytes` for the binary fields | ||
```python | ||
import gzip | ||
from webfront.models import StructuralModel | ||
contacts = "[[1,11,0.5], [2,30,0.8], [3,30,0.8]]" | ||
contacts_gz = gzip.compress(bytes(contacts,'utf-8')) | ||
structure = """ATOM 1 N VAL A 1 -0.701 1.770 1.392 1.00 4.92 N | ||
ATOM 2 CA VAL A 1 0.691 2.052 1.718 1.00 4.92 C | ||
ATOM 3 C VAL A 1 1.384 2.880 0.637 1.00 4.92 C | ||
ATOM 4 O VAL A 1 0.991 2.879 -0.532 1.00 4.92 O | ||
""" | ||
structure_gz = gzip.compress(bytes(structure,'utf-8')) | ||
model = StructuralModel(model_id=1,accession='PF17176',contacts=contacts_gz,structure=structure_gz) | ||
model.save() | ||
``` | ||
|
||
3. Generate the fixture using the `dumpdata` tool in django: | ||
```shell | ||
python manage.py dumpdata webfront --indent 4 | ||
``` | ||
```json | ||
[ | ||
{ | ||
"model": "webfront.structuralmodel", | ||
"pk": 1, | ||
"fields": { | ||
"accession": "PF17176", | ||
"contacts": "H4sIAOAnHWAC/4uONtQxNNQx0DON1VGINtIxNgCyLUBsYxg7FgCIHLXIJAAAAA==", | ||
"structure": "H4sIAOcnHWAC/42QMQ7DMAhF95yCCxRhOy54RFnbZIly/6MEcBWpSi2V5X9s/Qe27tsbohLAanLoC7S3Xg9CJvcJmSm0tOxC1s3o/irLT3oB7WbRGxAIn819Rqq5g5MMgMsXsMTBDWgbyRxAEeoDCv8FtNQGvzZsnw2FW3xBLaMnW346Aa6DA5lEAQAA" | ||
} | ||
} | ||
] | ||
``` | ||
4. Now you can use the generated JSON to included in one of the fixture files in `webfront/tests/`. | ||
|
||
In this example the generated fixture is included at the end of `webfront/tests/fixtures_structure.json`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.