-
Notifications
You must be signed in to change notification settings - Fork 0
Review ITGA7 #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Review ITGA7 #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Код классный, чистый и красивый. Мне все очень понравилось, за исключением пары мест, где я решил все же придраться :)
@@ -0,0 +1,206 @@ | |||
from __future__ import annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
обратная совместимость? здорово
return self.sequence[index] | ||
|
||
def __str__(self) -> str: | ||
return f"{self.sequence}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
оригинально, но я бы сделал все же
return f"{self.sequence}" | |
return str(self.sequence) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Но ведь sequence это уже str
return self.__class__(complemented_sequence) | ||
except AttributeError as e: | ||
raise NotImplementedError( | ||
"Complement method not implemented for this class." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
честно говоря, я не очень понял суть ошибки, исходя из ее текста. да и в коде выглядит странно: есть класс, в нем есть метод, но при этом эксепт говорит, что метода нет
gc_symbols = set("GCgc") | ||
gc_count = sum(1 for nucleotide in self.sequence if nucleotide in gc_symbols) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно и так, но можно и сяк:
gc_symbols = set("GCgc") | |
gc_count = sum(1 for nucleotide in self.sequence if nucleotide in gc_symbols) | |
gc_count = (self.sequence.count('G') + | |
self.sequence.count('C') + | |
self.sequence.count('g') + | |
self.sequence.count('c')) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну или вообще привести все к одному регистру локально с помощью .upper(), что выглядит тоже здраво
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так зато все считается за один прогон по строке. Думаю это не так существенно, один вариант чуть эффективнее, другой - чуть читаемее. Кому что больше нравится.
def __init__(self, sequence: str): | ||
self.sequence = sequence | ||
|
||
def __len__(self) -> int: | ||
return len(self.sequence) | ||
|
||
def __getitem__(self, index: int) -> str: | ||
return self.sequence[index] | ||
|
||
def __str__(self) -> str: | ||
return f"{self.sequence}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunder'ы можно не аннотировать, но и в их аннотации ничего критичного нет.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну да, это не имеет смысла, так что лучше не надо, потому что кто-то может не очень понять зачем так делать.
self.COMPLEMENT_MAP = { | ||
"A": "T", | ||
"C": "G", | ||
"G": "C", | ||
"T": "A", | ||
"a": "t", | ||
"c": "g", | ||
"g": "c", | ||
"t": "a", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мне кажется, что удобнее записывать буквы в верхнем регистре при их перечислении в константах (gc_symbols
, self.ALPHABET
, self.COMPLEMENT_MAP
и т.д.). Поступающую строку, даже если она в разных регистрах, можно приводить к одному уже внутри методов.
Но это дело вкуса, конечно)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут это теперь не константа. Константы это переменные которые объявляются в самом начале скрипта. Это просто классовый атрибут, поэтому его не надо делать капсом.
filtered_records = [] | ||
|
||
for record in records: | ||
gc_content = gc_fraction(record.seq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В этой ситуации можно использовать и другой метод (GC
) из класса Bio.SeqUtils
, осуществляющий подсчет GC-состава:
gc_content = gc_fraction(record.seq) | |
gc_content = Bio.SeqUtils.GC(record.seq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет! Очень классный код!
Ничего серьезного добавить к предыдущим комментариям не могу, нашла только пару мелочей: в транскрипции РНК, наверное, лучше все буквы делать одного регистра, и у меня не прошла проверка на аминокислотный алфавит.
А так все отлично! Спасибо за красивый код :)
@@ -0,0 +1,206 @@ | |||
from __future__ import annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это я возьму себе на заметку. Спасибо :)
|
||
def __init__(self, sequence: str): | ||
super().__init__(sequence) | ||
self.ALPHABET = set("GgLlYySsEeQqDdNnFfAaKkRrHhCcVvPpWwIiMmTt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я вызвала count_aa с символами BjouXZ, и мне выдало ответ вместо ошибки, что такие символы - не аминокислоты. Возможно, стоит доработать вывод ошибок.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Супер что прогоняешь код!
Review ITGA7