Commit 241d383b authored by Hervé  MENAGER's avatar Hervé MENAGER
Browse files

first project commit

parent a0dd92a6
from django.contrib import admin
from .models import Bibliography
admin.site.register(Bibliography)
from django.apps import AppConfig
class IppidbConfig(AppConfig):
name = 'ippidb'
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-14 11:12
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Bibliography',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('source', models.CharField(choices=[('PM', 'PubMed article'), ('PT', 'Patent')], max_length=2, verbose_name='Bibliographic type')),
('id_source', models.CharField(max_length=25, verbose_name='Bibliographic ID')),
('title', models.CharField(max_length=300, verbose_name='Title')),
('journal_name', models.CharField(max_length=50, verbose_name='Journal name')),
('authors_list', models.CharField(max_length=500, verbose_name='Authors list')),
('biblio_year', models.PositiveSmallIntegerField(verbose_name='Year')),
('cytotox', models.BooleanField(verbose_name='Cytotoxicity data')),
('in_silico', models.BooleanField(verbose_name='in silico study performed')),
('in_vitro', models.BooleanField(verbose_name='in vitro study performed')),
('in_vivo', models.BooleanField(verbose_name='in vivo study performed')),
('in_cellulo', models.BooleanField(verbose_name='in cellulo study performed')),
('pharmacokinetic', models.BooleanField(verbose_name='pharmacokinetic study performed')),
('xray', models.BooleanField(verbose_name='contains xray data')),
],
),
migrations.CreateModel(
name='BindingSite',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
),
migrations.CreateModel(
name='Complex',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('copy_nb', models.IntegerField(verbose_name='Number of copies')),
],
),
migrations.CreateModel(
name='Domain',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('pfam_acc', models.CharField(max_length=10, unique=True, verbose_name='Pfam Accession')),
('pfam_id', models.CharField(max_length=20, verbose_name='Pfam Family Identifier')),
('pfam_description', models.CharField(max_length=100, verbose_name='Pfam Description')),
('domainfamily', models.CharField(max_length=25, verbose_name='')),
],
),
migrations.CreateModel(
name='MolecularFunction',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('go_id', models.CharField(max_length=10, unique=True, verbose_name='Gene Ontology ID')),
('description', models.CharField(max_length=500, verbose_name='description')),
],
),
migrations.CreateModel(
name='Ppi',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('binding_site_id_1', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='binding_site_id_1', to='ippidb.BindingSite')),
('binding_site_id_2', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='binding_site_id_2', to='ippidb.BindingSite')),
('complex_id_1', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cplx_id_1', to='ippidb.Complex')),
('complex_id_2', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cplx_id_2', to='ippidb.Complex')),
],
),
migrations.CreateModel(
name='PpiArchitecture',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('pdb_id', models.CharField(max_length=4, verbose_name='PDB ID')),
('ppi_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.Ppi')),
],
),
migrations.CreateModel(
name='Protein',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uniprot_id', models.CharField(max_length=10, unique=True, verbose_name='Uniprot ID')),
('recommended_name_long', models.CharField(max_length=75, verbose_name='Uniprot Recommended Name (long)')),
('short_name', models.CharField(max_length=50, verbose_name='Short name')),
('gene_name', models.CharField(max_length=30, unique=True, verbose_name='Gene name')),
('entry_name', models.CharField(max_length=30, verbose_name='Entry name')),
('molecular_functions', models.ManyToManyField(to='ippidb.MolecularFunction')),
],
),
migrations.CreateModel(
name='Taxonomy',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('taxonomy_id', models.DecimalField(decimal_places=0, max_digits=4, unique=True, verbose_name='NCBI TaxID')),
('name', models.CharField(max_length=200, verbose_name='Organism name')),
],
),
migrations.AddField(
model_name='protein',
name='organism',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.Taxonomy'),
),
migrations.AddField(
model_name='complex',
name='protein_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.Protein'),
),
migrations.AddField(
model_name='bindingsite',
name='domain_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.Domain'),
),
migrations.AddField(
model_name='bindingsite',
name='protein_id',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='ippidb.Protein'),
),
]
This diff is collapsed.
{% load bootstrap3 %}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="{% bootstrap_css_url %}" />
<title>IPPI-DB Maintenance {% block title %}{% endblock %}</title>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">IPPI-DB</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="/ippidb/biblio/">Bibliographic references list<span class="sr-only">(current)</span></a></li>
<li><a href="/ippidb/biblio/add/">Add a new bibliographic reference<span class="sr-only">(current)</span></a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>
{% extends "base.html" %}
{% block title %}- biblio detail for {{object.title}} by {{object.authors_list}}{% endblock %}
{% block content %}
<p>{{ object.get_source_display }}</p>
<p>{{ object.id_source}}</p>
<p>{{ object.title }}</p>
<p>{{ object.journal_name }}</p>
<p>{{ object.authors_list }}</p>
<p>{{ object.biblio_year }}</p>
<p>{{ object.cytotox }}</p>
<p>{{ object.in_silico }}</p>
<p>{{ object.in_vitro }}</p>
<p>{{ object.in_vivo }}</p>
<p>{{ object.in_cellulo }}</p>
<p>{{ object.pharmacokinetic }}</p>
<p>{{ object.xray }}</p>
{% endblock %}
{% extends "base.html" %}
{% load bootstrap3 %}
{% block title %}- biblio edition{% endblock %}
{% block content %}
{% csrf_token %}
{% bootstrap_form form %}
<input type="submit" name="submit" value="Save" />
{% endblock %}
{% extends "base.html" %}
{% block title %}- biblios list{% endblock %}
{% block content %}
{% for biblio in object_list %}
<li><a href="{{biblio.get_absolute_url}}">{{ biblio.get_source_display }} {{ biblio.id_source}} - {{ biblio.title }}</a></li>
{% empty %}
<li>No articles yet.</li>
{% endfor %}
{% endblock %}
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from .views import BibliographyCreate, BibliographyUpdate, BibliographyDelete, BibliographyDetail, BibliographyList
urlpatterns = [
url(r'biblio/$', BibliographyList.as_view(), name='list'),
url(r'biblio/add/$', BibliographyCreate.as_view(), name='biblio-add'),
url(r'biblio/(?P<pk>[0-9]+)/$', BibliographyDetail.as_view(), name='biblio-detail'),
url(r'biblio/(?P<pk>[0-9]+)/edit/$', BibliographyUpdate.as_view(), name='biblio-update'),
url(r'biblio/(?P<pk>[0-9]+)/delete/$', BibliographyDelete.as_view(), name='biblio-delete'),
]
from django.http import HttpResponse
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.views.generic.detail import DetailView
from django.views.generic import ListView
from django.urls import reverse_lazy
from .models import Bibliography
class BibliographyCreate(CreateView):
model = Bibliography
fields = '__all__'
class BibliographyUpdate(UpdateView):
model = Bibliography
fields = '__all__'
class BibliographyDelete(DeleteView):
model = Bibliography
success_url = reverse_lazy('biblio-list')
class BibliographyDetail(DetailView):
model = Bibliography
fields = '__all__'
class BibliographyList(ListView):
model = Bibliography
from bioservices.eutils import EUtils
def get_pubmed_info(pmid):
eu = EUtils()
r = eu.EFetch('pubmed', pmid, retmode='dict', rettype='abstract')
article = r['PubmedArticleSet']['PubmedArticle']['MedlineCitation']['Article']
title = article['ArticleTitle']
authors_list = [a['LastName']+ ' ' + a['Initials'] for a in article['AuthorList']['Author']]
authors = ', '.join(authors_list)
journal_name = article['Journal']['Title']
biblio_year = article['Journal']['JournalIssue']['PubDate']['Year']
return {'title':title,
'journal_name':journal_name,
'biblio_year':biblio_year,
'authors_list': authors}
"""
Django settings for ippisite project.
Generated by 'django-admin startproject' using Django 1.10.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '&qc$2x5p&!qwvu2r=)sjp*jgg8a7ss97g8lwpennmu(q9ty4o$'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bootstrap3',
'ippidb'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'ippisite.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'ippisite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
STATIC_URL = '/static/'
"""ippisite URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.10/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^', include('ippidb.urls')),
url(r'^admin/', admin.site.urls),
]
"""
WSGI config for ippisite project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ippisite.settings")
application = get_wsgi_application()
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ippisite.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
Supports Markdown
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