Completed HW5#1
Conversation
Rewrite README with full description of BioSeqTools
SidorinAnton
left a comment
There was a problem hiding this comment.
Новый код и РИДМИ выглядят хорошо, однако оч жалко, что не поправлены моменты в aminoacids_tools и dna_rna_tools.
Вот отсюда:
Второй момент -- кеш пайчарма и .DS_Store. Этого в репе быть не должно )))
Никита рассказывал про файл .gitignore ну и + нужно хотя бы перед коммитом сделать git status ))
Ну и последнее:
- файлы в либах не принято называть с заглавных букв (т.е. Modules --> modules)
- название modules тоже не оч хорошее. Можно было бы назвать в духе bio_tools
- весь код в 1 коммите -- оч такое себе ))
| from typing import Dict | ||
|
|
||
|
|
||
| def calculate_percentage(seq: str) -> str: |
There was a problem hiding this comment.
Честно говоря, из названия не оч понятно, что за процент
| for amino_acid, count in amino_acid_counts.items(): | ||
| percentage = round(((count / total_amino_acids) * 100), 2) | ||
| amino_acid_percentages[amino_acid] = percentage | ||
| return f'Amino acids percentage of the sequence {seq}: {amino_acid_percentages}' |
There was a problem hiding this comment.
Всё-таки тут лучше возвращать именно словарь (amino_acid_percentages), т.к. он может понадобиться при расчете чего-то другого. Отображение можно сделать в другой функции, которая как раз принимала бы этот словарь
| weight = 18.02 # for the H and OH at the termini | ||
| for amino_acid in seq: | ||
| weight += amino_acid_weights[amino_acid] | ||
| return f'Molecular weight of the sequence {seq}: {round(weight, 2)} Da' |
There was a problem hiding this comment.
Та же история, что тут лучше возвращать число. Для отображения можно завести другую функцию
| return f'Molecular weight of the sequence {seq}: {round(weight, 2)} Da' | ||
|
|
||
|
|
||
| def calculate_hydrophobicity_eisenberg(sequence): |
| return f"Sequence {sequence}: Neutral" | ||
|
|
||
|
|
||
| def calculate_pI(sequence): |
| motif_idx += 1 | ||
| else: | ||
| break | ||
| if motif_idx == len(motif): |
| while seq_idx < len(seq): | ||
| motif_idx = 0 | ||
| chars_at_motif_idx = motif[motif_idx] | ||
| seq_char = seq[seq_idx] | ||
| if seq_char in chars_at_motif_idx: | ||
| motif_idx += 1 | ||
| while motif_idx < len(motif): | ||
| chars_at_motif_idx = motif[motif_idx] | ||
| seq_char = seq[seq_idx+motif_idx] | ||
| if seq_char in chars_at_motif_idx: | ||
| motif_idx += 1 | ||
| else: | ||
| break | ||
| if motif_idx == len(motif): | ||
| cleavage_sites.append(seq_idx + motif_idx) | ||
| seq_idx += 1 | ||
| return cleavage_sites |
| def is_peptide(seq: str) -> bool: | ||
| "Check whether the incoming sequence is an aminoacid" | ||
| if set(seq).issubset(all_aminoacids): # if set(seq) <= all_aminoacids | ||
| return True | ||
| raise ValueError(f'Incoming sequence {seq} is not a peptide') |
| def complement(sequence): | ||
| complement_dict = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', 'a': 't', | ||
| 't': 'a', 'c': 'g', 'g': 'c'} | ||
| complement_sequence = ''.join(complement_dict.get(base, base) |
| def reverse_complement(dna_sequence): | ||
| # можно также "complement_sequence = complement(dna_sequence)" | ||
| complement_dict = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', 'a': 't', | ||
| 't': 'a', 'c': 'g', 'g': 'c'} | ||
| complement_sequence = ''.join(complement_dict.get(base, base) | ||
| for base in dna_sequence) | ||
| return complement_sequence[::-1] |
There was a problem hiding this comment.
Есть же функции для reverse и complement


HW5 has been completed.