-
Notifications
You must be signed in to change notification settings - Fork 0
Add main script, modules and write README.md #1
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?
Conversation
nvaulin
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.
Привет!
Неплохая работа:) Обрати пожалуйста еще внимание на несколько комментов по предыдущему дз.
Баллы: 100/100
| dna = {"a", "t", "g", "c"} | ||
| rna = {"a", "u", "g", "c"} | ||
| rna_complements = { | ||
| "a": "u", | ||
| "u": "a", | ||
| "g": "c", | ||
| "c": "g", | ||
| "A": "U", | ||
| "U": "A", | ||
| "C": "G", | ||
| "G": "C", | ||
| } | ||
| dna_complements = { | ||
| "a": "t", | ||
| "t": "a", | ||
| "g": "c", | ||
| "c": "g", | ||
| "A": "T", | ||
| "T": "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.
Супер. Правильно что переименовала. Можно еще именно в этом конкретном случая назвать это всё именно капсом
DNA_COMPLEMENTS
Это в питоне называют константами (см. консультацию 09.10.2024)
| def reverse(seq: str) -> str: | ||
| seq = seq[::-1] | ||
| return seq |
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 reverse(seq: str) -> str: | |
| seq = seq[::-1] | |
| return seq | |
| def reverse(seq: str) -> str: | |
| return seq[::-1] |
| for nucleotide in seq: | ||
| if nucleotide == "T": | ||
| seq = seq.replace("T", "U") | ||
| if nucleotide == "t": | ||
| seq = seq.replace("t", "u") | ||
| return seq |
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.
Очень странно, ты итерируешься по нуклеотидам а меняешь строку. Вообще тебе тут просто не нужен цикл по нуклеотидам (зачем?). Да и проверка не нужна. Если нет - то и не заменится.
| for nucleotide in seq: | |
| if nucleotide == "T": | |
| seq = seq.replace("T", "U") | |
| if nucleotide == "t": | |
| seq = seq.replace("t", "u") | |
| return seq | |
| return seq.replace("t", "u").replace("T", "U") |
| def reverse_complement(seq: str) -> str: | ||
| reverse_complement_seq = "" | ||
| seq = seq[::-1] | ||
| if set(seq.lower()).issubset(dna): | ||
| for nucleotide in seq: | ||
| reverse_complement_seq += dna_complements[nucleotide] | ||
| else: | ||
| for nucleotide in seq: | ||
| reverse_complement_seq += rna_complements[nucleotide] | ||
| return reverse_complement_seq |
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.
Не надо повторять код reverse и complement в reverse_complement!!!
Просто вот так:
| def reverse_complement(seq: str) -> str: | |
| reverse_complement_seq = "" | |
| seq = seq[::-1] | |
| if set(seq.lower()).issubset(dna): | |
| for nucleotide in seq: | |
| reverse_complement_seq += dna_complements[nucleotide] | |
| else: | |
| for nucleotide in seq: | |
| reverse_complement_seq += rna_complements[nucleotide] | |
| return reverse_complement_seq | |
| def reverse_complement(seq: str) -> str: | |
| return reverse(complement(seq)) |
| for nucleotide in seq: | ||
| complement_seq += dna_complements[nucleotide] |
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.
Можно чуть компактнее и питоничнее
| for nucleotide in seq: | |
| complement_seq += dna_complements[nucleotide] | |
| complement_seq = "".join([dna_complements[nucl ] for nucl in seq]) |
То есть убрали цикл в одну строку ("List comprehension")
| def is_palindrom(seq: str) -> bool: | ||
| return seq == seq[::-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.
Кажется мне здесь врут.... Палиндром в биологии работает по другому:)
| def var_converse(var: (tuple, int, float)) -> tuple: | ||
| if isinstance(var, (int, float)): | ||
| var = (0, var) | ||
| return var |
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 quality_threshold(seq: str) -> float: | ||
| total_quality = 0 | ||
| for symbol in seq: | ||
| symbol_quality = ord(symbol) - 33 | ||
| total_quality += symbol_quality | ||
| mean_quality = total_quality / len(seq) | ||
| return mean_quality |
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.
Здесь тоже можно чуть скомпановать через List comprehension
Сможешь придумать как?
| """ | ||
| function = args[-1] | ||
| strands = args[:-1] | ||
| normal_output = [] |
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.
Почему normal_output? ахаха
Не совсем понял почему важно что он нормальный и где можно получить ненормальный
| if ( | ||
| gc_bounds[0] <= gc_content <= gc_bounds[1] | ||
| and length_bounds[0] <= length <= length_bounds[1] | ||
| and quality >= quality_threshold | ||
| ): | ||
| output_seqs[key] = seqs[key] |
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.
Красотища
Merge dev_branch with main to add main script, modules and write README.md to main