Commit 8c68a78f authored by Mathieu Courcelles's avatar Mathieu Courcelles

Creation of Git repository

parents
*.class
*.pyc
*.pyo
CLMSpipeline/settings.py
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CLMSpipeline</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
<nature>org.python.pydev.django.djangoNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>manage.py</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/CLMSpipeline</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
</pydev_project>
# # Copyright 2013 Mathieu Courcelles
# # Mike Tyers's lab / IRIC / Universite de Montreal
"""
This is the Admin module for the CLMSpipeline.
"""
# Import standard librariesdjang
# Import Django related libraries
#from django import forms
from django.contrib import admin
#from django.contrib.admin.sites import site
from django.contrib import messages
from django.db.models import get_app, get_models
#from django.utils.text import wrap
# Import project libraries
import CLMSpipeline.CLMSpipeline_app.models as CLMSpipelineModels
#from adminWidgets import *
## Register admin panels
admin.site.register(CLMSpipelineModels.Dataset)
admin.site.register(CLMSpipelineModels.FastaDB)
admin.site.register(CLMSpipelineModels.Instrument)
admin.site.register(CLMSpipelineModels.clPeptides)
admin.site.register(CLMSpipelineModels.searchAlgorithm)
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
pass
def backwards(self, orm):
pass
models = {
}
complete_apps = ['CLMSpipeline_app']
\ No newline at end of file
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Dataset.file_name'
db.add_column(u'CLMSpipeline_app_dataset', 'file_name',
self.gf('django.db.models.fields.CharField')(default='none', max_length=1000),
keep_default=False)
# Changing field 'Dataset.file'
db.alter_column(u'CLMSpipeline_app_dataset', 'file', self.gf('django.db.models.fields.files.FileField')(max_length=100))
def backwards(self, orm):
# Deleting field 'Dataset.file_name'
db.delete_column(u'CLMSpipeline_app_dataset', 'file_name')
# Changing field 'Dataset.file'
db.alter_column(u'CLMSpipeline_app_dataset', 'file', self.gf('django.db.models.fields.CharField')(max_length=1000))
models = {
u'CLMSpipeline_app.clpeptides': {
'Meta': {'object_name': 'clPeptides'},
'autovalidated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'dataset': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['CLMSpipeline_app.Dataset']", 'symmetrical': 'False'}),
'delta': ('django.db.models.fields.FloatField', [], {}),
'display_protein1': ('django.db.models.fields.CharField', [], {'max_length': '250'}),
'display_protein2': ('django.db.models.fields.CharField', [], {'max_length': '250'}),
'error': ('django.db.models.fields.FloatField', [], {}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'match_score': ('django.db.models.fields.FloatField', [], {}),
'notes': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'pep_link_pos_1': ('django.db.models.fields.IntegerField', [], {}),
'pep_link_pos_2': ('django.db.models.fields.IntegerField', [], {}),
'peptide1': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide2': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide_mod1': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'peptide_mod2': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'peptide_position1': ('django.db.models.fields.IntegerField', [], {}),
'peptide_position2': ('django.db.models.fields.IntegerField', [], {}),
'precursor_charge': ('django.db.models.fields.CharField', [], {'max_length': '5'}),
'precursor_intensity': ('django.db.models.fields.FloatField', [], {}),
'precursor_mz': ('django.db.models.fields.FloatField', [], {}),
'rank': ('django.db.models.fields.IntegerField', [], {}),
'rejected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'run_name': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
'scan_number': ('django.db.models.fields.IntegerField', [], {}),
'spectrum_intensity_coverage': ('django.db.models.fields.FloatField', [], {}),
'total_fragment_matches': ('django.db.models.fields.IntegerField', [], {}),
'validated': ('django.db.models.fields.CharField', [], {'max_length': '50'})
},
u'CLMSpipeline_app.dataset': {
'Meta': {'ordering': "['-experimentdate']", 'object_name': 'Dataset'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'experimentdate': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'fasta_db': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.FastaDB']"}),
'file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}),
'file_name': ('django.db.models.fields.CharField', [], {'max_length': '1000'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instrument_name': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.Instrument']"}),
'search_agorithm': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.searchAlgorithm']"})
},
u'CLMSpipeline_app.fastadb': {
'Meta': {'ordering': "['name']", 'object_name': 'FastaDB'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '200'})
},
u'CLMSpipeline_app.instrument': {
'Meta': {'ordering': "['name']", 'object_name': 'Instrument'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
},
u'CLMSpipeline_app.searchalgorithm': {
'Meta': {'ordering': "['name']", 'object_name': 'searchAlgorithm'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
}
}
complete_apps = ['CLMSpipeline_app']
\ No newline at end of file
## Copyright 2013 Mathieu Courcelles
## Mike Tyers's lab / IRIC / Universite de Montreal
"""
This is the data model module for the CLMSpipeline_app.
"""
# Import standard librariesdjang
import os.path
# Import Django related libraries
from django.db import models
# Import project libraries
## File upload
def upload_path_handler(instance, filename):
fn, ext = os.path.splitext(filename)
return "dataset/{id}{ext}".format(id=instance.pk, ext=ext)
# Create your models here.
class FastaDB(models.Model):
"""
This class holds the name of all the FASTA database.
"""
name = models.CharField(max_length=200, unique=True)
def __unicode__(self):
return self.name
class Meta:
ordering = ['name']
class Instrument(models.Model):
"""
This class holds the name of all the MS instruments.
"""
name = models.CharField(max_length=100, unique=True)
def __unicode__(self):
return str(self.name)
class Meta:
ordering = ['name']
class searchAlgorithm(models.Model):
"""
This class holds the name of all the search algorithms.
"""
name = models.CharField(max_length=100, unique=True)
def __unicode__(self):
return str(self.name)
class Meta:
ordering = ['name']
class Dataset(models.Model):
"""
This class holds dataset information of cross-linked peptides.
"""
experimentdate = models.DateTimeField("ExperimentDate", null=True,
blank=True)
creation_date = models.DateTimeField(auto_now_add=True)
file_name = models.CharField(max_length=1000)
file = models.FileField(upload_to=upload_path_handler)
instrument_name = models.ForeignKey(Instrument)
fasta_db = models.ForeignKey(FastaDB)
search_agorithm = models.ForeignKey(searchAlgorithm)
description = models.TextField('Detailed description', blank=True)
def __unicode__(self):
return str(self.pk)
class Meta:
ordering = ['-experimentdate']
class clPeptides(models.Model):
"""
This class holds details of cross-linked peptides.
"""
dataset = models.ManyToManyField(Dataset)
run_name = models.CharField(max_length=1000)
scan_number = models.IntegerField()
precursor_mz = models.FloatField()
precursor_charge = models.CharField(max_length=5)
precursor_intensity = models.FloatField()
rank = models.IntegerField()
match_score = models.FloatField()
spectrum_intensity_coverage = models.FloatField()
total_fragment_matches = models.IntegerField()
delta = models.FloatField()
error = models.FloatField()
peptide1 = models.CharField(max_length=100)
peptide_mod1 = models.CharField(max_length=150)
display_protein1 = models.CharField(max_length=250)
peptide_position1 = models.IntegerField()
pep_link_pos_1 = models.IntegerField()
peptide2 = models.CharField(max_length=100)
peptide_mod2 = models.CharField(max_length=150)
display_protein2 = models.CharField(max_length=250)
peptide_position2 = models.IntegerField()
pep_link_pos_2 = models.IntegerField()
autovalidated = models.BooleanField()
validated = models.CharField(max_length=50)
rejected = models.BooleanField()
notes = models.CharField(max_length=100)
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
# Code from http://stackoverflow.com/questions/9968532/django-admin-file-upload-with-current-model-id
_UNSAVED_FILEFIELD = 'unsaved_filefield'
@receiver(pre_save, sender=Dataset)
def skip_saving_file(sender, instance, **kwargs):
if not instance.pk and not hasattr(instance, _UNSAVED_FILEFIELD):
setattr(instance, _UNSAVED_FILEFIELD, instance.file)
instance.file = None
@receiver(post_save, sender=Dataset)
def save_file(sender, instance, created, **kwargs):
if created and hasattr(instance, _UNSAVED_FILEFIELD):
instance.file = getattr(instance, _UNSAVED_FILEFIELD)
instance.save()
# delete it if you feel uncomfortable...
# instance.__dict__.pop(_UNSAVED_FILEFIELD)
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)