Skip to content

Review EVI5L#35

Open
nvaulin wants to merge 1 commit intomainfrom
EVI5L
Open

Review EVI5L#35
nvaulin wants to merge 1 commit intomainfrom
EVI5L

Conversation

@nvaulin
Copy link
Copy Markdown
Member

@nvaulin nvaulin commented Feb 26, 2024

Review EVI5L

Copy link
Copy Markdown

@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.

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

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

def average_quality(record):
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 EVI5L.py
def __init__(self, sequence):
self.sequence = sequence

@abstractmethod
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 EVI5L.py
sequence_type: str = None # Это будет переопределено в подклассах

def __init__(self, sequence):
self.sequence = 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.

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

Comment thread EVI5L.py
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')
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

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 EVI5L.py


class DNASequence(NucleicAcidSequence):
sequence_type = 'DNA'
Copy link
Copy Markdown

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

Comment thread EVI5L.py
return (self.complement()).replace('T', 'U')


class RNASequence(NucleicAcidSequence):
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 EVI5L.py
return self.sequence[index]

def __str__(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.

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

Comment thread EVI5L.py
'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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

@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 thread EVI5L.py
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]:
Copy link
Copy Markdown

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 thread EVI5L.py
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'}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Если COMPLEMENT_MAP предполагается быть константой, лучше выделить его как атрибут класса или объявить его вне метода.

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 EVI5L.py
Comment on lines +115 to +116
def transcribe(self):
return (self.complement()).replace('T', 'U')
Copy link
Copy Markdown

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 thread EVI5L.py
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
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 EVI5L.py
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}
Copy link
Copy Markdown

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