Skip to content

Conversation

@nvaulin
Copy link
Member

@nvaulin nvaulin commented Feb 26, 2024

Review EVI5L

Copy link

@ailiskab-hub ailiskab-hub left a comment

Choose a reason for hiding this comment

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

Ну главное, что вы сделали задание)

-output (dict[str,str]) - filtered dictionary, which consists of entities that fulfill entered parameters.
"""

def average_quality(record):

Choose a reason for hiding this comment

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

Лучше отпределять функцию вне функции

def __init__(self, sequence):
self.sequence = sequence

@abstractmethod

Choose a reason for hiding this comment

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

По моему тут чего то не хватает

sequence_type: str = None # Это будет переопределено в подклассах

def __init__(self, sequence):
self.sequence = sequence

Choose a reason for hiding this comment

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

Тут необходимо добавить структуру с super(), чтобы наследование проходило корректно

return ''.join(COMPLEMENT_MAP[base] for base in self.sequence)

def check_alphabet(self):
valid_bases = set('ATGCU') if self.sequence_type == 'DNA' else set('AUGC')

Choose a reason for hiding this comment

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

Можно ввести переменные, чтобы не создавать множество кадый раз

Copy link
Member Author

Choose a reason for hiding this comment

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

Првильно



class DNASequence(NucleicAcidSequence):
sequence_type = 'DNA'

Choose a reason for hiding this comment

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

Если sequence_type это атрибут модели, то нужно было использовать self.sequence_type
И снова не хватает super()

return (self.complement()).replace('T', 'U')


class RNASequence(NucleicAcidSequence):

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):
return self.sequence

Choose a reason for hiding this comment

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

Очень много дублирующегося кода в ДНК и РНК, почему бы не реализовать это в родительском классе?

'E': 147.131, 'Q': 146.146, 'G': 75.067, 'H': 155.156, 'I': 131.175,
'L': 131.175, 'K': 146.189, 'M': 149.208, 'F': 165.192, 'P': 115.132,
'S': 105.093, 'T': 119.119, 'W': 204.228, 'Y': 181.191, 'V': 117.148}
return sum(MOLECULAR_MASS_MAP[aa] for aa in self.sequence)

Choose a reason for hiding this comment

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

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

Copy link

@stegodasha stegodasha left a comment

Choose a reason for hiding this comment

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

Вообще в целом ты большой/ая молодец))

Comment on lines +56 to +58
if len(seq) >= length_bounds[0] and len(seq) <= length_bounds[1] \
and average_quality(seq) >= quality_threshold \
and GC(seq.seq) >= gc_bounds[0] and GC(seq.seq) <= gc_bounds[1]:

Choose a reason for hiding this comment

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

Я бы постаралась вычислить GC состав один раз:

Suggested change
if len(seq) >= length_bounds[0] and len(seq) <= length_bounds[1] \
and average_quality(seq) >= quality_threshold \
and GC(seq.seq) >= gc_bounds[0] and GC(seq.seq) <= gc_bounds[1]:
gc_content = GC(seq.seq)
if len(seq) >= length_bounds[0] and len(seq) <= length_bounds[1] \
and average_quality(seq) >= quality_threshold \
and gc_bounds[0] <= gc_content <= gc_bounds[1]:

Comment on lines +94 to +95
COMPLEMENT_MAP = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', 'U': 'A'} if self.sequence_type == 'DNA' else {
'A': 'U', 'U': 'A', 'C': 'G', 'G': 'C'}

Choose a reason for hiding this comment

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

Если 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.

Ага, и когда он будет классовым атрибутом - то его уже не надо делать капсом

Comment on lines +115 to +116
def transcribe(self):
return (self.complement()).replace('T', 'U')

Choose a reason for hiding this comment

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

Я бы предложила использовать super() для вызова метода complement из родительского класса, чтобы убедиться, что будет использована правильная версия метода: return super().complement().replace('T', 'U')

Comment on lines +122 to +129
def __len__(self):
return len(self.sequence)

def __getitem__(self, index):
return self.sequence[index]

def __str__(self):
return self.sequence

Choose a reason for hiding this comment

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

Согласна с Алисой, я бы вынесла эти методы в родительский класс, чтобы их не дублировать

Comment on lines +153 to +156
MOLECULAR_MASS_MAP = {'A': 89.094, 'R': 174.203, 'N': 132.119, 'D': 133.104, 'C': 121.154,
'E': 147.131, 'Q': 146.146, 'G': 75.067, 'H': 155.156, 'I': 131.175,
'L': 131.175, 'K': 146.189, 'M': 149.208, 'F': 165.192, 'P': 115.132,
'S': 105.093, 'T': 119.119, 'W': 204.228, 'Y': 181.191, 'V': 117.148}

Choose a reason for hiding this comment

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

Я бы вынесла MOLECULAR_MASS_MAP отдельно как атрибут класса.

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.

3 participants