Skip to content

HW4_Toropov #2

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 34 commits into
base: main
Choose a base branch
from
Open

Conversation

artyomtorr
Copy link

@artyomtorr artyomtorr commented Sep 26, 2023

Add protein_tools.py and update README

@artyomtorr artyomtorr closed this Sep 26, 2023
@artyomtorr artyomtorr reopened this Sep 26, 2023
@artyomtorr artyomtorr changed the title Add protein_tools.py HW4_Toropov Oct 1, 2023
Copy link
Member

@nvaulin nvaulin left a comment

Choose a reason for hiding this comment

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

Привет:)

❗️ Напоминание напомнить всем членам команды посмотреть фидбек.

Ниже можете найти подробные комментарии по коду. Тут некоторые общие моменты:

  1. Очень классный README.
  2. Небольшая проблемка со структурой репозитория. Ваш README тоже должен был бы лежать в папке)
  3. Операции над белками. Здорово что сделали каждый по 3. Это чуть больше, чем нужно было на оценку, но мы же тут не за оценкой а за знаниями и навыками. Некоторые комментарии по коду
  • Не нашел вообще проблем с общей логикой за исключением каких-то пары моментов, которые отметил в коде.
  • Кое-где формат вывода не очень хороший, обратите внимания
  • Где-то высказал свои предложения по более питонистым решениям и неймингам.
  1. Хорошая история коммитов, хорошие сообщения. По коммитам прям видно как вы постепенно улучшали код. Тем не менее есть несколько коммитов, где за раз добавлено многовато). Лучше не кидать несколько функций в один коммит.
  2. Шо у вас CaptnClementine делает в pull-request'e?)
  3. По форматам выводов важное замечание. Лучше было бы возвращать в ваем случае словрь (ключ - белок в запросе, значение - результат), чем лист из тюплов. В мутациях мб стоило возвращать только список, и печатать какое то сообщение. Чтобы потом с этим списком можно было бы работать.
  4. Константы в начале кода - капсом!

Баллы

  • README 2.7/2.5
  • Операции работают, 5*1.5 = 7.5/7.5
  • За формат вывода -0.3
  • За качество кода -0.3 (кое-где нейминги и в начале прям по букве на строке - это сильно))

Итого: 9.6

Очень классная работа! Спасибо!

@@ -0,0 +1,336 @@
alphabet_protein = {
Copy link
Member

Choose a reason for hiding this comment

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

Круто что вы вынесли эти переменные отдельно вначале вне функций. Несколько моментов:

  1. Такие вещи в питоне называются "константами" и их принято называть целиком капсом
Suggested change
alphabet_protein = {
ALPHABET_PROTEIN = {
  1. Тут название понятное, но кажется можно придумать что-то получше. Что-то типа proteinogenic_aminoacids.

  2. На надо тут было разбирать каждую букву на отдальной строке... Понятно, что не все в одну строку, но по несколько АК на строке

Аналогично про все константы ниже


def is_protein(seq: str):
"""
Check the existence of a protein sequence, return boolean.
Copy link
Member

Choose a reason for hiding this comment

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

Ну оно не совсем existence проверяет)


def is_rna(seq: str):
"""
Check the existence of a RNA sequence, return boolean.
Copy link
Member

Choose a reason for hiding this comment

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

Аналогично про existance

Comment on lines +117 to +131
def compute_molecular_weight(protein: str) -> tuple:
"""
Compute molecular weight (g/mol) of protein sequence.

Argument:
- protein (str): protein sequence.

Return:
- tuple with protein sequence and computed molecular
weight (float rounded to 3 decimal places).
"""
molecular_weight = 0
for amino_acid in protein.upper():
molecular_weight += amino_acid_masses[amino_acid]
return protein, round(molecular_weight, 3)
Copy link
Member

Choose a reason for hiding this comment

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

Хорошая докстринга, здорово что упомянули размерность.
Разве что формат вывода у вашей функции немного странный. Я запускаю функцию типа compute_molecular_weight('MTNPQ) и я ожидаю получить число. А получаю кортеж.
Если бы у вас было много белков на входе, можно было бы выдать таблицу соотвествия белок->масса. Это надо сделать с помощью словаря (значение - белок). Кортеж тут не лучшее решение. По сути вы просто возвращаете белок который пользователь вам и дал)

Comment on lines +134 to +144
def compute_length(protein: str) -> tuple:
"""
Compute the length of the input protein sequence.

Argument:
- protein (str): protein sequence.

Return:
- tuple with protein sequence and computed length.
"""
return protein, len(protein)
Copy link
Member

Choose a reason for hiding this comment

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

Та же история про возвращение кортежа.
С подсчетом длины хитро:) Не поспоришь.
Это было бы на самом деле даже немного оправдано, если бы я мог давать аминокислоты в трехбуквенном коде

Comment on lines +283 to +286
if protein[-1] != "*":
raise ValueError("Stop (*) is absent")
if protein[0] != "M":
raise ValueError("Start (M) is absent")
Copy link
Member

Choose a reason for hiding this comment

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

У вас же есть аналогичные ошибки в translate_rna. Мб их не нужно дублировать.


Examples:
- "AUGGUAGGGAAAUUUUGA", "MVGKF*" -> "Protein without mutations."
- "AUGGUAGGGAAAUUUUGA", "MGGVF*" -> "Mutations:G2, V4."
Copy link
Member

Choose a reason for hiding this comment

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

Круто что вы показываете что заменилось! Тут было бы использовать все таки нотацию типа "K2N" где K - то что должно быть по РНК, и N - то что по факту

contain only three arguments: RNA sequence, protein sequence
and the name of procedure itself.
"""
*seqs, procedure = args
Copy link
Member

Choose a reason for hiding this comment

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

Это ок, как в прошлом ДЗ, но все таки в реальных тулах такое может быть не очень очевидно. Я бы сделал название процедуры именованным аргументом.

"""
*seqs, procedure = args
results = []
d_of_functions = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
d_of_functions = {
functions = {


**protein_tools.py** - is a tool which allows the performing of various procedures for a user entered protein sequences.

### Usage
Copy link
Member

Choose a reason for hiding this comment

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

Очень классное README, спасибо! Хорошо что написали вклад каждого члена команы:)

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.

5 participants