Skip to content

Review RNF34#41

Open
nvaulin wants to merge 1 commit intomainfrom
RNF34
Open

Review RNF34#41
nvaulin wants to merge 1 commit intomainfrom
RNF34

Conversation

@nvaulin
Copy link
Copy Markdown
Member

@nvaulin nvaulin commented Feb 26, 2024

Review RNF34

Copy link
Copy Markdown

@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. Мне кажется, что вы бы легко с ним справились)

Comment thread RNF34.py
from abc import ABC, abstractmethod


class BiologicalSequence(ABC):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Прекрасная работа с абстрактным классом. Все необходимые абстрактные методы учтены!

Comment thread RNF34.py
return self.sequence[slc]

def __str__(self):
return str(self.sequence)
Copy link
Copy Markdown

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

Comment thread RNF34.py
return str(self.sequence)

def __repr__(self):
return self.sequence
Copy link
Copy Markdown

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Верно подмечено!

Comment thread RNF34.py
return self.sequence

def is_valid_alphabet(self):
alphabet = type(self).ALPHABET
Copy link
Copy Markdown

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

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

Comment thread RNF34.py
Comment on lines +48 to +51
if set(self.sequence).issubset(alphabet):
return True
else:
return False
Copy link
Copy Markdown

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)

Comment thread RNF34.py


class AminoAcidSequence(BiologicalSequence):
ALPHABET = set("ACDEFGHIKLMNPQRSTVWY")
Copy link
Copy Markdown

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 thread RNF34.py
Comment on lines +98 to +99
def __str__(self):
return str(self.sequence)
Copy link
Copy Markdown

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 thread RNF34.py
Comment on lines +101 to +102
def __repr__(self):
return self.sequence
Copy link
Copy Markdown

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 thread RNF34.py
Comment on lines +106 to +109
if set(self.sequence).issubset(alphabet):
return True
else:
return False
Copy link
Copy Markdown

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 thread RNF34.py
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
"""
Copy link
Copy Markdown

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