Skip to content

Conversation

nvaulin
Copy link
Member

@nvaulin nvaulin commented Feb 26, 2024

Review ITGA7

Copy link

@NSapozhnikov NSapozhnikov left a 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

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}"

Choose a reason for hiding this comment

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

оригинально, но я бы сделал все же

Suggested change
return f"{self.sequence}"
return str(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.

Но ведь sequence это уже str

return self.__class__(complemented_sequence)
except AttributeError as e:
raise NotImplementedError(
"Complement method not implemented for this class."

Choose a reason for hiding this comment

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

честно говоря, я не очень понял суть ошибки, исходя из ее текста. да и в коде выглядит странно: есть класс, в нем есть метод, но при этом эксепт говорит, что метода нет

Comment on lines +74 to +75
gc_symbols = set("GCgc")
gc_count = sum(1 for nucleotide in self.sequence if nucleotide in gc_symbols)

Choose a reason for hiding this comment

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

можно и так, но можно и сяк:

Suggested change
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'))

Choose a reason for hiding this comment

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

ну или вообще привести все к одному регистру локально с помощью .upper(), что выглядит тоже здраво

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 +20 to +30
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}"

Choose a reason for hiding this comment

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

Dunder'ы можно не аннотировать, но и в их аннотации ничего критичного нет.

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 +92 to +101
self.COMPLEMENT_MAP = {
"A": "T",
"C": "G",
"G": "C",
"T": "A",
"a": "t",
"c": "g",
"g": "c",
"t": "a",
}

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 и т.д.). Поступающую строку, даже если она в разных регистрах, можно приводить к одному уже внутри методов.
Но это дело вкуса, конечно)

Copy link
Member Author

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)
Copy link

@rereremin rereremin Mar 8, 2024

Choose a reason for hiding this comment

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

В этой ситуации можно использовать и другой метод (GC) из класса Bio.SeqUtils, осуществляющий подсчет GC-состава:

Suggested change
gc_content = gc_fraction(record.seq)
gc_content = Bio.SeqUtils.GC(record.seq)

@rereremin
Copy link

Благодарю за выполненную работу!
Мои комментарии несли исключительно косметический характер, каких-то серьезных недочетов я не нашел и не увидел. Думаю, это можно считать комплиментом в Вашу сторону)
картинка-Программист-Спасибо-654

Copy link

@uzunmasha uzunmasha left a 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

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")

Choose a reason for hiding this comment

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

Я вызвала count_aa с символами BjouXZ, и мне выдало ответ вместо ошибки, что такие символы - не аминокислоты. Возможно, стоит доработать вывод ошибок.

Copy link
Member Author

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.

4 participants