Skip to content

Reference Python

mousetube_api.models

User

Bases: Model

Represents a user of the system.

Attributes:

Name Type Description
name_user str

The last name of the user.

first_name_user str

The first name of the user.

email_user str

The email address of the user.

unit_user str

The unit the user belongs to.

institution_user str

The institution the user belongs to.

address_user str

The address of the user.

country_user str

The country of the user.

Source code in mousetube_api/models.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class User(models.Model):
    """
    Represents a user of the system.

    Attributes:
        name_user (str): The last name of the user.
        first_name_user (str): The first name of the user.
        email_user (str): The email address of the user.
        unit_user (str, optional): The unit the user belongs to.
        institution_user (str, optional): The institution the user belongs to.
        address_user (str, optional): The address of the user.
        country_user (str, optional): The country of the user.
    """

    name_user = models.CharField(max_length=255)
    first_name_user = models.CharField(max_length=255)
    email_user = models.CharField(max_length=255)
    unit_user = models.CharField(max_length=255, blank=True, null=True)
    institution_user = models.CharField(max_length=255, blank=True, null=True)
    address_user = models.CharField(max_length=255, blank=True, null=True)
    country_user = models.CharField(max_length=255, blank=True, null=True)

    def __str__(self):
        """
        Returns the full name of the user.

        Returns:
            str: The full name of the user.
        """
        return f"{self.first_name_user} {self.name_user}"

__str__()

Returns the full name of the user.

Returns:

Name Type Description
str

The full name of the user.

Source code in mousetube_api/models.py
35
36
37
38
39
40
41
42
def __str__(self):
    """
    Returns the full name of the user.

    Returns:
        str: The full name of the user.
    """
    return f"{self.first_name_user} {self.name_user}"

Strain

Bases: Model

Represents a strain of a mouse.

Attributes:

Name Type Description
name_strain str

The name of the strain.

background str

The genetic background of the strain.

biblio_strain str

Bibliographical references related to the strain.

Source code in mousetube_api/models.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class Strain(models.Model):
    """
    Represents a strain of a mouse.

    Attributes:
        name_strain (str): The name of the strain.
        background (str): The genetic background of the strain.
        biblio_strain (str, optional): Bibliographical references related to the strain.
    """

    name_strain = models.CharField(max_length=255, unique=True)
    background = models.CharField(max_length=255)
    biblio_strain = models.TextField(blank=True, null=True)

    def __str__(self):
        """
        Returns the name of the strain as a string.

        Returns:
            str: The name of the strain.
        """
        return self.name_strain

    class Meta:
        verbose_name = "Strain"
        verbose_name_plural = "Strains"

__str__()

Returns the name of the strain as a string.

Returns:

Name Type Description
str

The name of the strain.

Source code in mousetube_api/models.py
59
60
61
62
63
64
65
66
def __str__(self):
    """
    Returns the name of the strain as a string.

    Returns:
        str: The name of the strain.
    """
    return self.name_strain

Subject

Bases: Model

Represents a subject (mouse) in the system.

Attributes:

Name Type Description
name_subject str

The name of the subject.

strain_subject Strain

The strain associated with the subject.

origin_subject str

The origin of the subject.

sex_subject str

The sex of the subject.

group_subject str

The group the subject belongs to.

genotype_subject str

The genotype of the subject.

treatment str

The treatment applied to the subject.

user User

The user associated with the subject.

Source code in mousetube_api/models.py
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
class Subject(models.Model):
    """
    Represents a subject (mouse) in the system.

    Attributes:
        name_subject (str): The name of the subject.
        strain_subject (Strain): The strain associated with the subject.
        origin_subject (str, optional): The origin of the subject.
        sex_subject (str, optional): The sex of the subject.
        group_subject (str, optional): The group the subject belongs to.
        genotype_subject (str, optional): The genotype of the subject.
        treatment (str, optional): The treatment applied to the subject.
        user (User): The user associated with the subject.
    """

    name_subject = models.CharField(max_length=255, unique=True)
    strain_subject = models.ForeignKey(Strain, on_delete=models.CASCADE)
    origin_subject = models.CharField(max_length=255, blank=True, null=True)
    sex_subject = models.CharField(max_length=255, blank=True, null=True)
    group_subject = models.CharField(max_length=255, blank=True, null=True)
    genotype_subject = models.CharField(max_length=255, blank=True, null=True)
    treatment = models.CharField(max_length=255, blank=True, null=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE)

    def __str__(self):
        """
        Returns the name of the subject.

        Returns:
            str: The name of the subject.
        """
        return self.name_subject

    class Meta:
        verbose_name = "Subject"
        verbose_name_plural = "Subjects"

__str__()

Returns the name of the subject.

Returns:

Name Type Description
str

The name of the subject.

Source code in mousetube_api/models.py
 97
 98
 99
100
101
102
103
104
def __str__(self):
    """
    Returns the name of the subject.

    Returns:
        str: The name of the subject.
    """
    return self.name_subject

Protocol

Bases: Model

Represents an experimental protocol.

Attributes:

Name Type Description
name_protocol str

The name of the protocol.

number_files int

The number of files associated with the protocol.

protocol_description str

A description of the protocol.

user User

The user associated with the protocol.

Source code in mousetube_api/models.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
class Protocol(models.Model):
    """
    Represents an experimental protocol.

    Attributes:
        name_protocol (str): The name of the protocol.
        number_files (int, optional): The number of files associated with the protocol.
        protocol_description (str): A description of the protocol.
        user (User): The user associated with the protocol.
    """

    name_protocol = models.CharField(max_length=255)
    number_files = models.IntegerField(blank=True, null=True)
    protocol_description = models.TextField(default="")
    user = models.ForeignKey(User, on_delete=models.CASCADE)

    def __str__(self):
        """
        Returns the name of the protocol.

        Returns:
            str: The name of the protocol.
        """
        return self.name_protocol

    class Meta:
        verbose_name = "Protocol"
        verbose_name_plural = "Protocols"

__str__()

Returns the name of the protocol.

Returns:

Name Type Description
str

The name of the protocol.

Source code in mousetube_api/models.py
127
128
129
130
131
132
133
134
def __str__(self):
    """
    Returns the name of the protocol.

    Returns:
        str: The name of the protocol.
    """
    return self.name_protocol

Experiment

Bases: Model

Represents an experiment.

Attributes:

Name Type Description
name_experiment str

The name of the experiment.

protocol Protocol

The protocol associated with the experiment.

group_subject str

The group of subjects involved in the experiment.

date_experiment date

The date of the experiment.

temperature str

The temperature during the experiment.

light_cycle str

The light cycle during the experiment.

microphone str

The microphone used in the experiment.

acquisition_hardware str

The hardware used for acquisition.

acquisition_software str

The software used for acquisition.

sampling_rate float

The sampling rate of the data.

bit_depth float

The bit depth of the data.

laboratory str

The laboratory where the experiment was conducted.

Source code in mousetube_api/models.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
class Experiment(models.Model):
    """
    Represents an experiment.

    Attributes:
        name_experiment (str): The name of the experiment.
        protocol (Protocol): The protocol associated with the experiment.
        group_subject (str, optional): The group of subjects involved in the experiment.
        date_experiment (date, optional): The date of the experiment.
        temperature (str, optional): The temperature during the experiment.
        light_cycle (str, optional): The light cycle during the experiment.
        microphone (str, optional): The microphone used in the experiment.
        acquisition_hardware (str, optional): The hardware used for acquisition.
        acquisition_software (str, optional): The software used for acquisition.
        sampling_rate (float, optional): The sampling rate of the data.
        bit_depth (float, optional): The bit depth of the data.
        laboratory (str, optional): The laboratory where the experiment was conducted.
    """

    name_experiment = models.CharField(max_length=255, unique=True)
    protocol = models.ForeignKey(Protocol, on_delete=models.CASCADE)
    group_subject = models.CharField(max_length=255, blank=True, null=True)
    date_experiment = models.DateField(blank=True, null=True)
    temperature = models.CharField(max_length=255, blank=True, null=True)
    light_cycle = models.CharField(max_length=255, blank=True, null=True)
    microphone = models.CharField(max_length=255, blank=True, null=True)
    acquisition_hardware = models.CharField(max_length=255, blank=True, null=True)
    acquisition_software = models.CharField(max_length=255, blank=True, null=True)
    sampling_rate = models.FloatField(blank=True, null=True)
    bit_depth = models.FloatField(blank=True, null=True)
    laboratory = models.CharField(max_length=255, blank=True, null=True)

    def __str__(self):
        """
        Returns the name of the experiment.

        Returns:
            str: The name of the experiment.
        """
        return self.name_experiment

    class Meta:
        verbose_name = "Experiment"
        verbose_name_plural = "Experiments"

__str__()

Returns the name of the experiment.

Returns:

Name Type Description
str

The name of the experiment.

Source code in mousetube_api/models.py
173
174
175
176
177
178
179
180
def __str__(self):
    """
    Returns the name of the experiment.

    Returns:
        str: The name of the experiment.
    """
    return self.name_experiment

File

Bases: Model

Represents a file associated with an experiment or subject.

Attributes:

Name Type Description
experiment Experiment

The experiment associated with the file.

subject Subject

The subject associated with the file.

file_number int

The number of the file.

link_file str

The URL link to the file.

notes_file str

Notes about the file.

doi_file str

The DOI of the file.

is_valid_link bool

Whether the link is valid.

Source code in mousetube_api/models.py
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
class File(models.Model):
    """
    Represents a file associated with an experiment or subject.

    Attributes:
        experiment (Experiment, optional): The experiment associated with the file.
        subject (Subject, optional): The subject associated with the file.
        file_number (int, optional): The number of the file.
        link_file (str, optional): The URL link to the file.
        notes_file (str, optional): Notes about the file.
        doi_file (str, optional): The DOI of the file.
        is_valid_link (bool): Whether the link is valid.
    """

    experiment = models.ForeignKey(
        Experiment, on_delete=models.CASCADE, blank=True, null=True
    )
    subject = models.ForeignKey(
        Subject, on_delete=models.CASCADE, blank=True, null=True
    )
    file_number = models.IntegerField(blank=True, null=True)
    link_file = models.URLField(blank=True, null=True)
    notes_file = models.TextField(blank=True, null=True)
    doi_file = models.CharField(max_length=255, blank=True, null=True)
    is_valid_link = models.BooleanField(default=False)

    def __str__(self):
        """
        Returns the link to the file.

        Returns:
            str: The URL link to the file.
        """
        return self.link_file

    class Meta:
        verbose_name = "File"
        verbose_name_plural = "Files"

__str__()

Returns the link to the file.

Returns:

Name Type Description
str

The URL link to the file.

Source code in mousetube_api/models.py
213
214
215
216
217
218
219
220
def __str__(self):
    """
    Returns the link to the file.

    Returns:
        str: The URL link to the file.
    """
    return self.link_file

PageView

Bases: Model

Represents a page view for tracking purposes.

Attributes:

Name Type Description
path str

The path of the page.

date date

The date of the page view.

count int

The number of views for the page on the given date.

Source code in mousetube_api/models.py
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
class PageView(models.Model):
    """
    Represents a page view for tracking purposes.

    Attributes:
        path (str): The path of the page.
        date (date): The date of the page view.
        count (int): The number of views for the page on the given date.
    """

    path = models.CharField(max_length=255)
    date = models.DateField(auto_now_add=True)
    count = models.PositiveIntegerField(default=0)

    class Meta:
        unique_together = ("path", "date")

    def __str__(self):
        """
        Returns a string representation of the page view.

        Returns:
            str: The path, date, and count of the page view.
        """
        return f"{self.path} - {self.date} ({self.count})"

__str__()

Returns a string representation of the page view.

Returns:

Name Type Description
str

The path, date, and count of the page view.

Source code in mousetube_api/models.py
244
245
246
247
248
249
250
251
def __str__(self):
    """
    Returns a string representation of the page view.

    Returns:
        str: The path, date, and count of the page view.
    """
    return f"{self.path} - {self.date} ({self.count})"