-
Notifications
You must be signed in to change notification settings - Fork 0
Review RNF34 #41
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 RNF34 #41
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.
Очень хорошая работа! Все условия наследования и полиморфизма учтены. Код написан в соответствии с PEP8. Я бы выделила следующие основные замечания:
- Не реализована функция is_valid_alphabet(), с помощью которой можно было бы проверять соответствие последовательности при создании экземпляров класса
- В коде нет аннотаций
Ну и конечно, не выполнено задание по парсеру fastq с использованием BioPython. Мне кажется, что вы бы легко с ним справились)
from abc import ABC, abstractmethod | ||
|
||
|
||
class BiologicalSequence(ABC): |
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[slc] | ||
|
||
def __str__(self): | ||
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.
Хорошо, что перестраховались и точно определили строковую переменную) Но, тут это не обязательно, так как self.sequence - уже строка.
return str(self.sequence) | |
return self.sequence |
return str(self.sequence) | ||
|
||
def __repr__(self): | ||
return 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.
В методе repr мы должны скорее передавать техническую информацию о классе. Я тоже в своей дз передала self.sequence, но при ревью подумала, что правильнее было бы использовать строку c указанием класса.
return self.sequence | |
return f'NucleicAcid("{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 self.sequence | ||
|
||
def is_valid_alphabet(self): | ||
alphabet = type(self).ALPHABET |
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.
Класс! Учтено условие задания по полиморфизма классов NucleicAcid, DNASequence и RNASequence.
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.
Я бы еще добавил что поскольку алфавит больше не внешняя константа, а классновый атрибут
самый обычный классовый атрибут
то его больше не надо писать в капсе
if set(self.sequence).issubset(alphabet): | ||
return True | ||
else: | ||
return False |
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.
Очень разумная проверка, однако в данном случае нет необходимости возвращать явным образом True и False. Вот так будет отлично работать:
if set(self.sequence).issubset(alphabet): | |
return True | |
else: | |
return False | |
return set(self.sequence).issubset(alphabet) |
|
||
|
||
class AminoAcidSequence(BiologicalSequence): | ||
ALPHABET = set("ACDEFGHIKLMNPQRSTVWY") |
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.
ALPHABET = set("ACDEFGHIKLMNPQRSTVWY") | |
alphabet = set("ACDEFGHIKLMNPQRSTVWY") |
def __str__(self): | ||
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.
def __str__(self): | |
return str(self.sequence) | |
def __str__(self): | |
return self.sequence |
def __repr__(self): | ||
return 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.
def __repr__(self): | |
return self.sequence | |
def __repr__(self): | |
return f'AminoAcidSequence("{self.sequence}")' |
if set(self.sequence).issubset(alphabet): | ||
return True | ||
else: | ||
return False |
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.
if set(self.sequence).issubset(alphabet): | |
return True | |
else: | |
return False | |
return set(self.sequence).issubset(alphabet): |
""" | ||
Calculates the frequency of each amino acid in a protein sequence or sequences. | ||
|
||
:param sequences: protein sequence or sequences | ||
:type sequences: str or list of str | ||
:return: dictionary with the frequency of each amino acid | ||
:rtype: dict | ||
""" |
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 RNF34