User:Lindenb/Notebook/UMR915/2012/04/02: Difference between revisions

From OpenWetWare
< User:Lindenb‎ | Notebook‎ | UMR915‎ | 2012‎ | 04
Jump to navigationJump to search
No edit summary
Line 268: Line 268:
</pre>
</pre>


<pre>$ cat articles/models.py


from django.db import models
# Create your models here.</pre>
change to:
<pre>d$ cat articles/models.py
from django.db import models
# Create your models here.
class Article(models.Model):
year = models.IntegerField()
title = models.TextField()
</pre>
Add articles in 'settings.py' /INSTALLED_APPS
<pre>INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'articles'</pre>
tell dgango about this new table:
<pre>$ python manage.py sql articles
$ python manage.py sql articles
BEGIN;
CREATE TABLE "articles_article" (
    "id" integer NOT NULL PRIMARY KEY,
    "year" integer NOT NULL,
    "title" text NOT NULL
)
;
COMMIT;
COMMIT;</pre>
Now, run syncdb again to create those model tables in your database:
<pre>$ python manage.py syncdb
Creating tables ...
Creating table articles_article
Installing custom SQL ...
Installing indexes ...
No fixtures found.
</pre>


__NOTOC__
__NOTOC__

Revision as of 06:56, 2 April 2012

Project name <html><img src="/images/9/94/Report.png" border="0" /></html> Main project page
<html><img src="/images/c/c3/Resultset_previous.png" border="0" /></html>Previous entry<html>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</html>Next entry<html><img src="/images/5/5c/Resultset_next.png" border="0" /></html>

Daily

variant_effect_predictor.pl

Fix for proxy

replace

 	unless(getstore($url, $target_file) == 200)

by

      my $status = system("/usr/bin/curl --proxy 'http://proxy:3128' -o '$target_file' -L  '$url'");
     (...)
      my $status2 = system("/usr/bin/curl --proxy 'http://proxy:3128' -o '$target_file' -L --create-dirs '$BIOPERL_URL,'");


some problems with the bioperl install, downloaded the tar.gz and moved the perl modules to the directory 'Bio':

in the directory 'Bio':

Align
AlignIO
Annotation
Assembly
Biblio
bioperl-1.2.3
Cluster
ClusterIO
Coordinate
Das
DB
EnsEMBL
Event
Expression
Factory
Graphics
Index
LiveSeq
Location
Map
MapIO
Matrix
Ontology
OntologyIO
Phenotype
Root
Search
SearchIO
Seq
SeqFeature
SeqIO
Structure
Symbol
Taxonomy
tmp
Tools
Tree
TreeIO
Variation


Run

 perl variant_effect_predictor.pl  --regulatory --sift=b  --polyphen=b  --regulatory --input_file 20120327.rs.vcf.gz  --format vcf -o  20120402.vcf --vcf



DJANGO

install ubuntu:

  sudo apt-get install python-django

start a new project

  $ django-admin startproject gene2pubmed


$ find gene2pubmed/
gene2pubmed/
gene2pubmed/urls.py
gene2pubmed/__init__.py
gene2pubmed/manage.py
gene2pubmed/settings.py

Edit gene2pubmed/settings.py and set the default db to sqlite3:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'gene2pubmed.sqlite3',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

set the local time in gene2pubmed/settings.py

TIME_ZONE = 'Europe/Paris'

synchronize installation for sessions, messages, etc...

python manage.py syncdb

$ python manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): y
Please enter either "yes" or "no": yes
Username (Leave blank to use 'lindenb'): 
E-mail address: xxxx@xxxx.xxx
Password: 
Password (again): 
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
No fixtures found.

check the databases created:

$ sqlite3 gene2pubmed.sqlite3 
SQLite version 3.7.7 2011-06-23 19:49:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .schema
CREATE TABLE "auth_group" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(80) NOT NULL UNIQUE
);
CREATE TABLE "auth_group_permissions" (
    "id" integer NOT NULL PRIMARY KEY,
    "group_id" integer NOT NULL,
    "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id"),
    UNIQUE ("group_id", "permission_id")
);
CREATE TABLE "auth_message" (
    "id" integer NOT NULL PRIMARY KEY,
    "user_id" integer NOT NULL REFERENCES "auth_user" ("id"),
    "message" text NOT NULL
);
CREATE TABLE "auth_permission" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(50) NOT NULL,
    "content_type_id" integer NOT NULL,
    "codename" varchar(100) NOT NULL,
    UNIQUE ("content_type_id", "codename")
);
CREATE TABLE "auth_user" (
    "id" integer NOT NULL PRIMARY KEY,
    "username" varchar(30) NOT NULL UNIQUE,
    "first_name" varchar(30) NOT NULL,
    "last_name" varchar(30) NOT NULL,
    "email" varchar(75) NOT NULL,
    "password" varchar(128) NOT NULL,
    "is_staff" bool NOT NULL,
    "is_active" bool NOT NULL,
    "is_superuser" bool NOT NULL,
    "last_login" datetime NOT NULL,
    "date_joined" datetime NOT NULL
);
CREATE TABLE "auth_user_groups" (
    "id" integer NOT NULL PRIMARY KEY,
    "user_id" integer NOT NULL,
    "group_id" integer NOT NULL REFERENCES "auth_group" ("id"),
    UNIQUE ("user_id", "group_id")
);
CREATE TABLE "auth_user_user_permissions" (
    "id" integer NOT NULL PRIMARY KEY,
    "user_id" integer NOT NULL,
    "permission_id" integer NOT NULL REFERENCES "auth_permission" ("id"),
    UNIQUE ("user_id", "permission_id")
);
CREATE TABLE "django_content_type" (
    "id" integer NOT NULL PRIMARY KEY,
    "name" varchar(100) NOT NULL,
    "app_label" varchar(100) NOT NULL,
    "model" varchar(100) NOT NULL,
    UNIQUE ("app_label", "model")
);
CREATE TABLE "django_session" (
    "session_key" varchar(40) NOT NULL PRIMARY KEY,
    "session_data" text NOT NULL,
    "expire_date" datetime NOT NULL
);
CREATE TABLE "django_site" (
    "id" integer NOT NULL PRIMARY KEY,
    "domain" varchar(100) NOT NULL,
    "name" varchar(50) NOT NULL
);
CREATE INDEX "auth_group_permissions_1e014c8f" ON "auth_group_permissions" ("permission_id");
CREATE INDEX "auth_group_permissions_425ae3c4" ON "auth_group_permissions" ("group_id");
CREATE INDEX "auth_message_403f60f" ON "auth_message" ("user_id");
CREATE INDEX "auth_permission_1bb8f392" ON "auth_permission" ("content_type_id");
CREATE INDEX "auth_user_groups_403f60f" ON "auth_user_groups" ("user_id");
CREATE INDEX "auth_user_groups_425ae3c4" ON "auth_user_groups" ("group_id");
CREATE INDEX "auth_user_user_permissions_1e014c8f" ON "auth_user_user_permissions" ("permission_id");
CREATE INDEX "auth_user_user_permissions_403f60f" ON "auth_user_user_permissions" ("user_id");
CREATE INDEX "django_session_3da3d3d8" ON "django_session" ("expire_date");


testing the development server:

$ python gene2pubmed/manage.py  runserver
Validating models...

0 errors found
Django version 1.3, using settings 'gene2pubmed.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[02/Apr/2012 07:57:11] "GET / HTTP/1.1" 200 2061

It worked!

Congratulations on your first Django-powered page.

Of course, you haven't actually done any work yet. Here's what to do next:

  • If you plan to use a database, edit the DATABASES setting in gene2pubmed/settings.py.
  • Start your first app by running python gene2pubmed/manage.py startapp [appname].

You're seeing this message because you have DEBUG = True in your Django settings file and you haven't configured any URLs. Get to work!

creating model

$ python manage.py startapp articles

$ find .
.
./urls.py
./__init__.py
./urls.pyc
./settings.pyc
./articles
./articles/__init__.py
./articles/models.py
./articles/tests.py
./articles/views.py
./manage.py
./settings.py
./gene2pubmed.sqlite3
./__init__.pyc
$ cat articles/models.py 

from django.db import models

# Create your models here.

change to:

d$ cat articles/models.py
from django.db import models

# Create your models here.

class Article(models.Model):
	year = models.IntegerField()
	title = models.TextField()


Add articles in 'settings.py' /INSTALLED_APPS

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'articles'

tell dgango about this new table:

$ python manage.py sql articles
$ python manage.py sql articles
BEGIN;
CREATE TABLE "articles_article" (
    "id" integer NOT NULL PRIMARY KEY,
    "year" integer NOT NULL,
    "title" text NOT NULL
)
;
COMMIT;

COMMIT;

Now, run syncdb again to create those model tables in your database:

$ python manage.py syncdb
Creating tables ...
Creating table articles_article
Installing custom SQL ...
Installing indexes ...
No fixtures found.