-
Notifications
You must be signed in to change notification settings - Fork 0
Review EVI5L #35
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
base: main
Are you sure you want to change the base?
Review EVI5L #35
Conversation
ailiskab-hub
left a comment
There was a problem hiding this 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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно ввести переменные, чтобы не создавать множество кадый раз
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут тоже много дублирующегося кода, некоторые из методов можно было реализовать в BiologicalSequence, чтобы избегать повторения
stegodasha
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вообще в целом ты большой/ая молодец))
| 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]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы постаралась вычислить GC состав один раз:
| 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]: |
| 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'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если COMPLEMENT_MAP предполагается быть константой, лучше выделить его как атрибут класса или объявить его вне метода.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ага, и когда он будет классовым атрибутом - то его уже не надо делать капсом
| def transcribe(self): | ||
| return (self.complement()).replace('T', 'U') |
There was a problem hiding this comment.
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')
| def __len__(self): | ||
| return len(self.sequence) | ||
|
|
||
| def __getitem__(self, index): | ||
| return self.sequence[index] | ||
|
|
||
| def __str__(self): | ||
| return self.sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласна с Алисой, я бы вынесла эти методы в родительский класс, чтобы их не дублировать
| 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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы вынесла MOLECULAR_MASS_MAP отдельно как атрибут класса.
Review EVI5L