Skip to content

Conversation

@vnbar
Copy link
Owner

@vnbar vnbar commented Oct 6, 2024

Merge dev_branch with main to add main script, modules and write README.md to main

Copy link

@nvaulin nvaulin left a comment

Choose a reason for hiding this comment

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

Привет!
Неплохая работа:) Обрати пожалуйста еще внимание на несколько комментов по предыдущему дз.

Баллы: 100/100

Comment on lines +5 to +26
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",
}
Copy link

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)

Comment on lines +38 to +40
def reverse(seq: str) -> str:
seq = seq[::-1]
return seq
Copy link

Choose a reason for hiding this comment

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

Можно сразу:

Suggested change
def reverse(seq: str) -> str:
seq = seq[::-1]
return seq
def reverse(seq: str) -> str:
return seq[::-1]

Comment on lines +30 to +35
for nucleotide in seq:
if nucleotide == "T":
seq = seq.replace("T", "U")
if nucleotide == "t":
seq = seq.replace("t", "u")
return seq
Copy link

Choose a reason for hiding this comment

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

Очень странно, ты итерируешься по нуклеотидам а меняешь строку. Вообще тебе тут просто не нужен цикл по нуклеотидам (зачем?). Да и проверка не нужна. Если нет - то и не заменится.

Suggested change
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")

Comment on lines +54 to +63
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
Copy link

Choose a reason for hiding this comment

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

Не надо повторять код reverse и complement в reverse_complement!!!
Просто вот так:

Suggested change
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))

Comment on lines +46 to +47
for nucleotide in seq:
complement_seq += dna_complements[nucleotide]
Copy link

Choose a reason for hiding this comment

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

Можно чуть компактнее и питоничнее

Suggested change
for nucleotide in seq:
complement_seq += dna_complements[nucleotide]
complement_seq = "".join([dna_complements[nucl ] for nucl in seq])

То есть убрали цикл в одну строку ("List comprehension")

Comment on lines +76 to +77
def is_palindrom(seq: str) -> bool:
return seq == seq[::-1]
Copy link

Choose a reason for hiding this comment

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

Кажется мне здесь врут.... Палиндром в биологии работает по другому:)

Comment on lines +13 to +16
def var_converse(var: (tuple, int, float)) -> tuple:
if isinstance(var, (int, float)):
var = (0, var)
return var
Copy link

Choose a reason for hiding this comment

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

Ну, в целом выносить это в отдельную функцию было бы не обязательно, но ладно:)

Comment on lines +4 to +10
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
Copy link

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 = []
Copy link

Choose a reason for hiding this comment

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

Почему normal_output? ахаха
Не совсем понял почему важно что он нормальный и где можно получить ненормальный

Comment on lines +88 to +93
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]
Copy link

Choose a reason for hiding this comment

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

Красотища

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.

2 participants