Conversation
nvaulin
left a comment
There was a problem hiding this comment.
Привет:
По дз 15: 23/25 (BiologicalSequence) + 23/25 (FastQ) = 46/50 * 0.5 (сдано после дедлайна) = 23
По дз 18: 10/10 + 8/8 + 32/32 = 50/50
| COMPLEMENT_DICT_DNA = { | ||
| "A": "T", | ||
| "a": "t", | ||
| "G": "C", | ||
| "g": "c", | ||
| "T": "A", | ||
| "t": "a", | ||
| "C": "G", | ||
| "c": "g", | ||
| } | ||
|
|
||
| # creating a dictionary for the complementary sequence | ||
| # from mRNA 5' - 3' to cDNA 3' - 5' | ||
| COMPLEMENT_DICT_RNA = { | ||
| "A": "T", | ||
| "a": "t", | ||
| "G": "C", | ||
| "g": "c", | ||
| "U": "A", | ||
| "u": "a", | ||
| "C": "G", | ||
| "c": "g", | ||
| } | ||
|
|
||
| # creating a dictionary for transcription DNA -> RNA (5' - 3' DNA -> | ||
| # 5' - 3' RNA) |
There was a problem hiding this comment.
Ну кстати тут уже столько констант, что их имеет смысл вынести в отдельный файлик
| def __init__(self, sequence: str): | ||
| self.sequence = sequence | ||
|
|
||
| def __len__(self): | ||
| return len(self.sequence) | ||
|
|
||
| def __getitem__(self, index): | ||
| return self.__class__(self.sequence[index]) | ||
|
|
||
| def __str__(self): | ||
| return self.sequence | ||
|
|
||
| def __repr__(self): | ||
| return f'{self.__class__.__name__}(sequence="{self.sequence}")' | ||
|
|
||
| def is_sequence_correct(self): | ||
| return set(self.sequence).issubset(self.alphabet) |
There was a problem hiding this comment.
Тут должны быть только дефенишины, без начинки функций. Абстрактные классы нужны чтобы зафиксировать наличие какого-то интерфейса, а не реализовывать его
| return set(self.sequence).issubset(self.alphabet) | ||
|
|
||
|
|
||
| class NucleicAcidSequence(BiologicalSequence, ABC): |
There was a problem hiding this comment.
а вот тут наследоваться от ABC уже не надо
| gc_bounds: int | list[int] = [0, 100], | ||
| length_bounds: int | list[int] = [0, 2**32], |
There was a problem hiding this comment.
Нельзя делать изменяемые типы данных в качестве знаний по умолчанию! В первом семестре мы смотрели к каким проблемам это может привести
| if not os.path.exists(input_fastq): | ||
| raise FileNotFoundError("Input fastq file does not exists") | ||
|
|
||
| if type(gc_bounds) is int and gc_bounds > 0: |
| elif type(gc_bounds) is not tuple and len(gc_bounds) != 2: | ||
| return "Wrong value for the gc_bounds argument" | ||
| elif ( | ||
| type(gc_bounds) is not list |
There was a problem hiding this comment.
| type(gc_bounds) is not list | |
| not isinstance(gc_bounds, list) |
А если кортеж?
| "--output", | ||
| dest="output", | ||
| default=None, | ||
| type=str, |
There was a problem hiding this comment.
советую посмотреть на: https://docs.python.org/3/library/argparse.html#filetype-objects
| import argparse | ||
| from bioinf_utility import filter_fastq | ||
| import logging |
There was a problem hiding this comment.
| import argparse | |
| from bioinf_utility import filter_fastq | |
| import logging | |
| import argparse | |
| import logging | |
| from bioinf_utility import filter_fastq |
| result = subprocess.run( | ||
| ["python", "filter_fastq_CLI.py"] + args, capture_output=True, text=True | ||
| ) |
There was a problem hiding this comment.
круто что протестирован запуск и командной строки!
| assert ( | ||
| len(records) == filtered_seqs_amount | ||
| ), f"Expected {filtered_seqs_amount} sequences, got {len(records)}" |
There was a problem hiding this comment.
Было бы конечно хорошо еще знать какие-именно сиквенсы не прошли. Но это вопрос уже к данным. То есть тогда стоит (в реальном мире) потратиться на то чтобы подготовить набор правильных фаликов-ответов на каждый набор аргументов. И сравнивать файлики. Но это уже отдельная история
No description provided.