Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Review RNF34 #41

wants to merge 1 commit into from

Conversation

nvaulin
Copy link
Member

@nvaulin nvaulin commented Feb 26, 2024

Review RNF34

Copy link

@EkaterinShitik EkaterinShitik left a 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):

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошо, что перестраховались и точно определили строковую переменную) Но, тут это не обязательно, так как self.sequence - уже строка.

Suggested change
return str(self.sequence)
return self.sequence

return str(self.sequence)

def __repr__(self):
return self.sequence

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В методе repr мы должны скорее передавать техническую информацию о классе. Я тоже в своей дз передала self.sequence, но при ревью подумала, что правильнее было бы использовать строку c указанием класса.

Suggested change
return self.sequence
return f'NucleicAcid("{self.sequence}")'

Copy link
Member Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Класс! Учтено условие задания по полиморфизма классов NucleicAcid, DNASequence и RNASequence.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы еще добавил что поскольку алфавит больше не внешняя константа, а классновый атрибут
самый обычный классовый атрибут

то его больше не надо писать в капсе

Comment on lines +48 to +51
if set(self.sequence).issubset(alphabet):
return True
else:
return False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Очень разумная проверка, однако в данном случае нет необходимости возвращать явным образом True и False. Вот так будет отлично работать:

Suggested change
if set(self.sequence).issubset(alphabet):
return True
else:
return False
return set(self.sequence).issubset(alphabet)



class AminoAcidSequence(BiologicalSequence):
ALPHABET = set("ACDEFGHIKLMNPQRSTVWY")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ALPHABET = set("ACDEFGHIKLMNPQRSTVWY")
alphabet = set("ACDEFGHIKLMNPQRSTVWY")

Comment on lines +98 to +99
def __str__(self):
return str(self.sequence)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __str__(self):
return str(self.sequence)
def __str__(self):
return self.sequence

Comment on lines +101 to +102
def __repr__(self):
return self.sequence

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __repr__(self):
return self.sequence
def __repr__(self):
return f'AminoAcidSequence("{self.sequence}")'

Comment on lines +106 to +109
if set(self.sequence).issubset(alphabet):
return True
else:
return False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if set(self.sequence).issubset(alphabet):
return True
else:
return False
return set(self.sequence).issubset(alphabet):

Comment on lines +114 to +121
"""
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
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно было бы маленько подправить докстринг при переносе функции в новую программу :)
И тут же добавлю, что во всем коде совсем нет аннотаций( Кажется, с ними правда приятней смотреть на код.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants