Commit 86907e31 authored by Mathieu Courcelles's avatar Mathieu Courcelles

Functional parser for Xi, xQuest, pLink

parent 79fba212
......@@ -2,3 +2,7 @@
*.pyc
*.pyo
CLMSpipeline/settings.py
CLMSpipeline/CLMSpipeline_app/site_media
.pydevproject
.project
.settingsCLMSpipeline/CLMSpipeline_app/site_media/dataset
......@@ -5,6 +5,8 @@
<pydev_variables_property name="org.python.pydev.PROJECT_VARIABLE_SUBSTITUTION">
<key>DJANGO_MANAGE_LOCATION</key>
<value>manage.py</value>
<key>DJANGO_SETTINGS_MODULE</key>
<value>CLMSpipeline.settings</value>
</pydev_variables_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/CLMSpipeline</path>
......
......@@ -22,7 +22,7 @@ from django.dispatch import receiver
# Import project libraries
import CLMSpipeline.CLMSpipeline_app.models as CLMSpipelineModels
from CLMSpipeline.CLMSpipeline_app.parser.XiParser import XiParser
from CLMSpipeline.CLMSpipeline_app.parser.parser_generic import parser_generic
import export
#from adminWidgets import *
......@@ -31,7 +31,7 @@ class CLPeptideAdmin(admin.ModelAdmin):
actions = ['make_Xi_csv']
exportFields = OrderedDict( [('run_name', 'run_name'),
exportXiFields = OrderedDict( [('run_name', 'run_name'),
('scan_number', 'scan_number'),
('precursor_mz','precursor_mz'),
('precursor_charge','precursor_charge'),
......@@ -63,9 +63,9 @@ class CLPeptideAdmin(admin.ModelAdmin):
'total_fragment_matches',
'display_protein1', 'peptide1', 'peptide_position1', 'pep1_link_pos',
'display_protein2', 'peptide2', 'peptide_position2', 'pep2_link_pos',
'link_type', 'autovalidated', 'not_decoy')
'link_type', 'cross_link', 'autovalidated', 'not_decoy')
list_filter = ('dataset', 'link_type', 'autovalidated', 'not_decoy', 'rejected' )
list_filter = ('dataset', 'link_type', 'cross_link', 'autovalidated', 'not_decoy', 'rejected' )
search_fields = ('display_protein1', 'peptide1',
'display_protein2', 'peptide2')
......@@ -73,7 +73,7 @@ class CLPeptideAdmin(admin.ModelAdmin):
def make_Xi_csv(self, request, queryset):
return export.make_Xi_csv(self, request, queryset,
self.exportFields, 'CLPeptide')
self.exportXiFields, 'CLPeptide')
make_Xi_csv.short_description = 'Export as Xi CSV'
......@@ -111,29 +111,13 @@ class CLPeptideAdmin(admin.ModelAdmin):
class DatasetAdmin(admin.ModelAdmin):
actions = ['make_Xi_csv']
exportFields = OrderedDict( [('Display ID', 'displayId'),
('Name', 'name'),
('URI','uri'),
('Description','description'),
('Status','status'),
('Abstract','abstract'),
('Created by','created_by'),
('DB Entry creation date','creation_date'),
('DB Entry modification date','modification_date'),
])
date_hierarchy = 'creation_date'
list_display = ('name', 'prefix', 'file', 'instrument_name', 'fasta_db',
list_display = ('name', 'prefix', 'file', 'cross_linker', 'instrument_name', 'fasta_db',
'search_algorithm', 'description', 'parsing_status',
'creation_date', 'get_CLPeptides_URL')
list_filter = ('instrument_name', 'fasta_db', 'search_algorithm')
list_filter = ('cross_linker', 'instrument_name', 'fasta_db', 'search_algorithm')
readonly_fields = ('parsing_log', 'parsing_status')
......@@ -143,9 +127,8 @@ class DatasetAdmin(admin.ModelAdmin):
@receiver(post_save, sender=CLMSpipelineModels.Dataset)
def process_file(sender, instance, created, **kwargs):
if instance.parsing_status == False and instance.parsing_log == '':
instance.parsing_log = XiParser.parseXiResults(instance)
if instance.parsing_status == False and created == False:
instance.parsing_log = parser_generic.parseResults(instance)
def get_readonly_fields(self, request, obj=None):
......@@ -153,6 +136,9 @@ class DatasetAdmin(admin.ModelAdmin):
if obj != None and obj.parsing_status:
readonly_fields.extend(['file'])
readonly_fields.extend(['extra_file'])
readonly_fields.extend(['search_algorithm'])
readonly_fields.extend(['cross_linker'])
return readonly_fields
......@@ -166,6 +152,7 @@ class DatasetAdmin(admin.ModelAdmin):
## Register admin panels
admin.site.register(CLMSpipelineModels.Dataset, DatasetAdmin)
admin.site.register(CLMSpipelineModels.CrossLinker)
admin.site.register(CLMSpipelineModels.FastaDB)
admin.site.register(CLMSpipelineModels.Instrument)
admin.site.register(CLMSpipelineModels.CLPeptide, CLPeptideAdmin)
......
# -*- 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):
# Changing field 'CLPeptide.total_fragment_matches'
db.alter_column(u'CLMSpipeline_app_clpeptide', 'total_fragment_matches', self.gf('django.db.models.fields.IntegerField')())
def backwards(self, orm):
# Changing field 'CLPeptide.total_fragment_matches'
db.alter_column(u'CLMSpipeline_app_clpeptide', 'total_fragment_matches', self.gf('django.db.models.fields.FloatField')())
models = {
u'CLMSpipeline_app.clpeptide': {
'Meta': {'ordering': "['-match_score']", 'object_name': 'CLPeptide'},
'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'}),
'link_type': ('django.db.models.fields.IntegerField', [], {}),
'match_score': ('django.db.models.fields.FloatField', [], {}),
'not_decoy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'notes': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'pep1_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'pep2_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'peptide1': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide2': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide_position1': ('django.db.models.fields.IntegerField', [], {}),
'peptide_position2': ('django.db.models.fields.IntegerField', [], {}),
'peptide_wo_mod1': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'peptide_wo_mod2': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'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': "['-creation_date']", 'object_name': 'Dataset'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'description': ('django.db.models.fields.TextField', [], {'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'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instrument_name': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.Instrument']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'parsing_log': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}),
'parsing_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'prefix': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'search_algorithm': ('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
# -*- 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 model 'CrossLinker'
db.create_table(u'CLMSpipeline_app_crosslinker', (
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=100)),
))
db.send_create_signal(u'CLMSpipeline_app', ['CrossLinker'])
# Adding field 'Dataset.cross_linker'
db.add_column(u'CLMSpipeline_app_dataset', 'cross_linker',
self.gf('django.db.models.fields.related.ForeignKey')(default=None, to=orm['CLMSpipeline_app.CrossLinker']),
keep_default=False)
# Adding field 'CLPeptide.cross_link'
db.add_column(u'CLMSpipeline_app_clpeptide', 'cross_link',
self.gf('django.db.models.fields.BooleanField')(default=False),
keep_default=False)
def backwards(self, orm):
# Deleting model 'CrossLinker'
db.delete_table(u'CLMSpipeline_app_crosslinker')
# Deleting field 'Dataset.cross_linker'
db.delete_column(u'CLMSpipeline_app_dataset', 'cross_linker_id')
# Deleting field 'CLPeptide.cross_link'
db.delete_column(u'CLMSpipeline_app_clpeptide', 'cross_link')
models = {
u'CLMSpipeline_app.clpeptide': {
'Meta': {'ordering': "['-match_score']", 'object_name': 'CLPeptide'},
'autovalidated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'cross_link': ('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'}),
'link_type': ('django.db.models.fields.IntegerField', [], {}),
'match_score': ('django.db.models.fields.FloatField', [], {}),
'not_decoy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'notes': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'pep1_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'pep2_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'peptide1': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide2': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide_position1': ('django.db.models.fields.IntegerField', [], {}),
'peptide_position2': ('django.db.models.fields.IntegerField', [], {}),
'peptide_wo_mod1': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'peptide_wo_mod2': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'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.crosslinker': {
'Meta': {'ordering': "['name']", 'object_name': 'CrossLinker'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
},
u'CLMSpipeline_app.dataset': {
'Meta': {'ordering': "['-creation_date']", 'object_name': 'Dataset'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'cross_linker': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.CrossLinker']"}),
'description': ('django.db.models.fields.TextField', [], {'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'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instrument_name': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.Instrument']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'parsing_log': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}),
'parsing_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'prefix': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'search_algorithm': ('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
# -*- 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.extra_file'
db.add_column(u'CLMSpipeline_app_dataset', 'extra_file',
self.gf('django.db.models.fields.files.FileField')(default=None, max_length=100, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Dataset.extra_file'
db.delete_column(u'CLMSpipeline_app_dataset', 'extra_file')
models = {
u'CLMSpipeline_app.clpeptide': {
'Meta': {'ordering': "['-match_score']", 'object_name': 'CLPeptide'},
'autovalidated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'cross_link': ('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'}),
'link_type': ('django.db.models.fields.IntegerField', [], {}),
'match_score': ('django.db.models.fields.FloatField', [], {}),
'not_decoy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'notes': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'pep1_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'pep2_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'peptide1': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide2': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide_position1': ('django.db.models.fields.IntegerField', [], {}),
'peptide_position2': ('django.db.models.fields.IntegerField', [], {}),
'peptide_wo_mod1': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'peptide_wo_mod2': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'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.crosslinker': {
'Meta': {'ordering': "['name']", 'object_name': 'CrossLinker'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
},
u'CLMSpipeline_app.dataset': {
'Meta': {'ordering': "['-creation_date']", 'object_name': 'Dataset'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'cross_linker': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.CrossLinker']"}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'extra_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', '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'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instrument_name': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.Instrument']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'parsing_log': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'blank': 'True'}),
'parsing_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'prefix': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'search_algorithm': ('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
# -*- 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):
# Changing field 'Dataset.parsing_log'
db.alter_column(u'CLMSpipeline_app_dataset', 'parsing_log', self.gf('django.db.models.fields.CharField')(max_length=1000, null=True))
def backwards(self, orm):
# Changing field 'Dataset.parsing_log'
db.alter_column(u'CLMSpipeline_app_dataset', 'parsing_log', self.gf('django.db.models.fields.CharField')(default='', max_length=1000))
models = {
u'CLMSpipeline_app.clpeptide': {
'Meta': {'ordering': "['-match_score']", 'object_name': 'CLPeptide'},
'autovalidated': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'cross_link': ('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'}),
'link_type': ('django.db.models.fields.IntegerField', [], {}),
'match_score': ('django.db.models.fields.FloatField', [], {}),
'not_decoy': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'notes': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'pep1_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'pep2_link_pos': ('django.db.models.fields.IntegerField', [], {}),
'peptide1': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide2': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'peptide_position1': ('django.db.models.fields.IntegerField', [], {}),
'peptide_position2': ('django.db.models.fields.IntegerField', [], {}),
'peptide_wo_mod1': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'peptide_wo_mod2': ('django.db.models.fields.CharField', [], {'max_length': '150'}),
'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.crosslinker': {
'Meta': {'ordering': "['name']", 'object_name': 'CrossLinker'},
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'})
},
u'CLMSpipeline_app.dataset': {
'Meta': {'ordering': "['-creation_date']", 'object_name': 'Dataset'},
'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
'cross_linker': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.CrossLinker']"}),
'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
'extra_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', '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'}),
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'instrument_name': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['CLMSpipeline_app.Instrument']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
'parsing_log': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'blank': 'True'}),
'parsing_status': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'prefix': ('django.db.models.fields.CharField', [], {'max_length': '25'}),
'search_algorithm': ('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
......@@ -48,6 +48,22 @@ class AdminURLMixin(object):
# Create your models here.
class CrossLinker(models.Model):
"""
This class holds the name of all the cross-linkers.
"""
name = models.CharField(max_length=100, unique=True)
def __unicode__(self):
return self.name
class Meta:
ordering = ['name']
class FastaDB(models.Model):
"""
This class holds the name of all the FASTA database.
......@@ -71,7 +87,7 @@ class Instrument(models.Model):
name = models.CharField(max_length=100, unique=True)
def __unicode__(self):
return str(self.name)
return self.name
class Meta:
ordering = ['name']
......@@ -101,9 +117,16 @@ class Dataset(models.Model, AdminURLMixin):
name = models.CharField(max_length=100)
prefix = models.CharField(max_length=25, help_text="Short name that will be appeded in comparison.")
prefix = models.CharField(max_length=25,
help_text='Short name that will be appeded in comparison.')
file = models.FileField(upload_to=upload_path_handler,
help_text='pLink note: Merge the files ending with xlink_qry.proteins.txt from 1.sample\\search folder.')
extra_file = models.FileField(upload_to=upload_path_handler, blank=True,
help_text='pLink only: select pLink_combine.spectra.xls from 2.report\\sample1 folder. This file is used to filter FDR filtered hits.')
file = models.FileField(upload_to=upload_path_handler)
cross_linker = models.ForeignKey(CrossLinker)
instrument_name = models.ForeignKey(Instrument)
......@@ -115,7 +138,7 @@ class Dataset(models.Model, AdminURLMixin):
parsing_status = models.BooleanField(default=False)
parsing_log = models.CharField(max_length=1000, blank=True)
parsing_log = models.CharField(max_length=1000, blank=True, null=True)
def formated_url(self):
......@@ -124,10 +147,7 @@ class Dataset(models.Model, AdminURLMixin):
def __unicode__(self):
return str(self.pk)
def save(self, *args, **kwargs):
self.parsing_log = ''
super(Dataset, self).save(*args, **kwargs)
class Meta:
ordering = ['-creation_date']
......@@ -138,12 +158,17 @@ class Dataset(models.Model, AdminURLMixin):
# Code for dataset file upload
# Code from http://stackoverflow.com/questions/9968532/django-admin-file-upload-with-current-model-id
_UNSAVED_FILEFIELD = 'unsaved_filefield'
_UNSAVED_FILEFIELD_EXTRA = 'unsaved_filefield_extra'
@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
if not instance.pk and not hasattr(instance, _UNSAVED_FILEFIELD_EXTRA) and instance.extra_file:
setattr(instance, _UNSAVED_FILEFIELD_EXTRA, instance.extra_file)
instance.extra_file = None
......@@ -153,8 +178,11 @@ def save_file(sender, instance, created, **kwargs):
if created and hasattr(instance, _UNSAVED_FILEFIELD):
instance.file = getattr(instance, _UNSAVED_FILEFIELD)
if created and hasattr(instance, _UNSAVED_FILEFIELD_EXTRA):
instance.extra_file = getattr(instance, _UNSAVED_FILEFIELD_EXTRA)
instance.save()
# delete it if you feel uncomfortable...
# instance.__dict__.pop(_UNSAVED_FILEFIELD)
......@@ -196,7 +224,7 @@ class CLPeptide(models.Model):
spectrum_intensity_coverage = models.FloatField()
total_fragment_matches = models.FloatField('# Fragments')
total_fragment_matches = models.IntegerField('# Fragments')
delta = models.FloatField()
......@@ -239,6 +267,8 @@ class CLPeptide(models.Model):
link_type = models.IntegerField(choices=LINK_TYPE_CHOICES)
cross_link = models.BooleanField()
not_decoy = models.BooleanField()
......@@ -261,20 +291,24 @@ class CLPeptide(models.Model):
"""
self.link_type = 1
self.cross_link = False
if self.peptide_wo_mod1 == self.peptide_wo_mod2:
self.link_type = 1
self.cross_link = True
elif self.display_protein1 == self.display_protein2:
self.link_type = 2
self.cross_link = True
else:
if self.pep2_link_pos == -1:
self.link_type = 4
elif self.peptide2 == 'none':
elif self.pep2_link_pos > -1 and self.peptide_wo_mod2 == '-':
self.link_type = 3
def isDecoy(self):
......
......@@ -15,20 +15,20 @@ import re
# Import project libraries
from CLMSpipeline.CLMSpipeline_app.models import CLPeptide
from CLMSpipeline.CLMSpipeline_app.models import Dataset
from parser_generic import InvalidFileFormatException
class XiInvalidFileFormatException(Exception):
def __init__(self, value):
self.value = value