1 from django.db import models
2 from htswfrontend import settings
4 class Primer(models.Model):
5 primer_name = models.CharField(max_length=100, db_index=True)
6 primer_seq = models.CharField(max_length=50, blank=True, null=True)
7 notes = models.TextField(blank=True)
9 return '%s' % (self.primer_name)
11 ordering = ["primer_name"]
13 list_display = ('primer_name','primer_seq','notes')
16 'fields': (('primer_name'),('primer_seq'),('notes'))
20 class Antibody(models.Model):
21 antigene = models.CharField(max_length=500, db_index=True)
23 # SQL to add column: alter table fctracker_antibody add column "nickname" varchar(20) NULL;
24 nickname = models.CharField(max_length=20,blank=True,null=True, db_index=True,verbose_name = 'Short Name')
25 catalog = models.CharField(max_length=50, unique=True, db_index=True)
26 antibodies = models.CharField(max_length=500, db_index=True)
27 source = models.CharField(max_length=500, blank=True, db_index=True)
28 biology = models.TextField(blank=True)
29 notes = models.TextField(blank=True)
31 return '%s - %s (%s)' % (self.antigene, self.antibodies, self.catalog)
33 verbose_name_plural = "antibodies"
34 ordering = ["antigene"]
36 list_display = ('antigene','nickname','antibodies','catalog','source','biology','notes')
37 list_filter = ('antibodies','source')
40 'fields': (('antigene','nickname','antibodies'),('catalog','source'),('biology'),('notes'))
44 class Cellline(models.Model):
45 cellline_name = models.CharField(max_length=100, unique=True, db_index=True)
46 notes = models.TextField(blank=True)
48 return '%s' % (self.cellline_name)
51 ordering = ["cellline_name"]
54 list_display = ('cellline_name','notes')
57 'fields': (('cellline_name'),('notes'),)
61 class Condition(models.Model):
62 condition_name = models.CharField(max_length=2000, unique=True, db_index=True)
63 notes = models.TextField(blank=True)
65 return '%s' % (self.condition_name)
68 ordering = ["condition_name"]
71 list_display = ('condition_name','notes')
74 'fields': (('condition_name'),('notes'),)
78 class Species(models.Model):
79 scientific_name = models.CharField(max_length=256, unique=False, db_index=True, core=True)
80 common_name = models.CharField(max_length=256, blank=True)
81 use_genome_build = models.CharField(max_length=100, blank=False, null=False)
84 return '%s (%s)|%s' % (self.scientific_name, self.common_name, self.use_genome_build)
87 verbose_name_plural = "species"
88 ordering = ["scientific_name"]
93 'fields': (('scientific_name', 'common_name'), ('use_genome_build'))
97 class Affiliation(models.Model):
98 name = models.CharField(max_length=256, db_index=True, core=True,verbose_name='Group Name')
99 contact = models.CharField(max_length=256, null=True, blank=True,verbose_name='Contact Name')
100 email = models.EmailField(null=True,blank=True)
104 if self.contact != '':
105 str += ' ('+self.contact+')'
109 ordering = ["name","contact"]
110 unique_together = (("name", "contact"),)
113 list_display = ('name','contact','email')
116 'fields': (('name','contact','email'))
120 class Library(models.Model):
121 library_id = models.CharField(max_length=30, unique=True, db_index=True, core=True)
122 library_name = models.CharField(max_length=100, unique=True, core=True)
123 library_species = models.ForeignKey(Species, core=True)
124 cell_line = models.ForeignKey(Cellline,core=True)
125 condition = models.ForeignKey(Condition,core=True)
126 antibody = models.ForeignKey(Antibody,blank=True,null=True,core=True)
127 # New field Aug/25/08. SQL: alter table fctracker_library add column "lib_affiliation" varchar(256) NULL;
128 affiliations = models.ManyToManyField(Affiliation,related_name='library_affiliations',null=True,filter_interface=models.HORIZONTAL)
129 # New field Aug/19/08
130 # SQL to add column: alter table fctracker_library add column "replicate" smallint unsigned NULL;
131 REPLICATE_NUM = ((1,1),(2,2),(3,3),(4,4))
132 replicate = models.PositiveSmallIntegerField(choices=REPLICATE_NUM,default=1)
135 ('INPUT_RXLCh','INPUT_RXLCh'),
136 ('ChIP-seq', 'ChIP-seq'),
137 ('Sheared', 'Sheared'),
138 ('RNA-seq', 'RNA-seq'),
139 ('Methyl-seq', 'Methyl-seq'),
140 ('DIP-seq', 'DIP-seq'),
142 experiment_type = models.CharField(max_length=50, choices=EXPERIMENT_TYPES, default='ChIP-seq')
144 creation_date = models.DateField(blank=True, null=True)
145 made_for = models.CharField(max_length=50, blank=True,verbose_name = 'ChIP/DNA/RNA Made By')
146 made_by = models.CharField(max_length=50, blank=True,verbose_name = 'Library Made By')
148 PROTOCOL_END_POINTS = (
149 ('Completed','Completed'),
151 ('Sample', 'Raw sample'),
152 ('Progress', 'In progress'),
153 ('1A', 'Ligation, then gel'),
154 ('PCR', 'Ligation, then PCR'),
155 ('1Ab', 'Ligation, PCR, then gel'),
156 ('1Aa', 'Ligation, gel, then PCR'),
157 ('2A', 'Ligation, PCR, gel, PCR'),
159 stopping_point = models.CharField(max_length=50, choices=PROTOCOL_END_POINTS, default='Completed')
160 amplified_from_sample = models.ForeignKey('self', blank=True, null=True)
162 undiluted_concentration = models.DecimalField("Template concentr. (ng/ul)",max_digits=5, decimal_places=2, blank=True, null=True)
163 ten_nM_dilution = models.BooleanField()
164 successful_pM = models.DecimalField(max_digits=5, decimal_places=2,blank=True, null=True)
165 avg_lib_size = models.IntegerField(default=225, blank=True, null=True)
166 notes = models.TextField(blank=True)
169 return '%s: %s' % (self.library_id, self.library_name)
172 verbose_name_plural = "libraries"
173 ordering = ["-library_id"]
175 def antibody_name(self):
176 return self.antibody.nickname
178 def affiliation(self):
179 affs = self.affiliations.all().order_by('name')
183 ar.append(t.__str__())
184 return '%s' % (", ".join(ar))
187 date_hierarchy = "creation_date"
190 search_fields = ['affiliations__name','affiliations__contact','library_name', 'library_id','made_by','made_for','antibody__antigene','antibody__catalog','antibody__antibodies','antibody__source','cell_line__cellline_name','library_species__scientific_name','library_species__common_name','library_species__use_genome_build']
191 list_display = ('affiliation','library_id', 'library_name','experiment_type','replicate','antibody_name','cell_line','made_by','creation_date')
192 list_display_links = ('library_id', 'library_name')
193 list_filter = ('experiment_type','affiliations','library_species','made_for', 'made_by','replicate')
196 'fields': (('replicate','library_id','library_name'),('library_species'),('experiment_type'),('cell_line','condition','antibody'),)
198 ('Creation Information:', {
199 'fields' : (('made_for', 'made_by', 'creation_date'), ('stopping_point', 'amplified_from_sample'), ('avg_lib_size','undiluted_concentration', 'ten_nM_dilution', 'successful_pM'), 'notes',)
201 ('Library/Project Affiliation:', {
202 'fields' : (('affiliations'),)