Bioinf_tools_were_made#1
Conversation
nvaulin
left a comment
There was a problem hiding this comment.
Привет
Я там оставил комментарии по коду. В целом работа хорошая, где то мелочи типа неймингов и организации циклов.
Молодец!
10/10*0.5 = 5
| run_dna_rna_tools("ATGC", procedure='reverse_complement') # 'GCAT' | ||
|
|
||
| ### run_fastq_filter | ||
| run_fastq_filter(gc_bounds=50) |
There was a problem hiding this comment.
Кажется тут этот пример не запустится, тут же нет данных:)
| procedure, sequences = args[-1], args[:-1] | ||
| if procedure not in dna_rna_tools.PROCEDURES_DICT.keys(): | ||
| raise ValueError("Wrong procedure") | ||
| rna_dna_tools_result_list = [] |
There was a problem hiding this comment.
Да просто было бы достаточно
| rna_dna_tools_result_list = [] | |
| results = [] |
| for sequence in sequences: | ||
| dna_rna_tools.check_user_input(sequence) | ||
| rna_dna_tools_result_list.append( | ||
| dna_rna_tools.PROCEDURES_DICT[procedure](sequence) | ||
| ) |
There was a problem hiding this comment.
Вот это максимально питонично выглядит!
| def run_dna_rna_tools(*args): | ||
| procedure, sequences = args[-1], args[:-1] |
| def run_protein_tools(sequences: (str, tuple[str] or list[str]), **kwargs: str) -> dict: | ||
| """ | ||
| Process protein sequence by one of the developed tools.\n | ||
| Run one procedure at a time: | ||
| - Search for conserved amino acids residues in protein sequence | ||
| - Search for alternative frames in a protein sequences | ||
| - Convert protein sequences to RNA or DNA sequences | ||
| - Reverse the protein sequences from one-letter to three-letter format and vice-versa | ||
| - Define molecular weight of the protein sequences | ||
|
|
||
| All functions except *search_for_alt_frames* are letter case sensitive\n | ||
| If only one sequence provided - *sequences* can be string.\n | ||
| If more - please provide *sequences* as list or tuple.\n | ||
| Provide protein sequence in one letter code.\n | ||
| You can obtain one letter code from three letter code with *three_one_letter_code*\n | ||
| If more information needed please see README or desired docstring | ||
|
|
||
| Arguments: | ||
| - sequences (str, list[str] or tuple[str]): sequences to process | ||
| - procedure (str]: desired procedure: | ||
| - "search_for_motifs" | ||
| - "search_for_alt_frames" | ||
| - "convert_to_nucl_acids" | ||
| - "three_one_letter_code" | ||
| - "define_molecular_weight" | ||
|
|
||
| For "search_for_motif" procedure provide: | ||
| - motif (str): desired motif to check presense in every given sequence\n | ||
| Example: motif = "GA" | ||
| - overlapping (bool): count (True) or skip (False) overlapping matches. (Optional)\n | ||
| Example: overlapping = False | ||
|
|
||
| For "search_for_alt_frames" procedure provide: | ||
| - alt_start_aa (str): the name of an amino acid that is encoded by alternative start codon (Optional)\n | ||
| Example: alt_start_aa = "I" | ||
|
|
||
| For "convert_to_nucl_acids" procedure provide: | ||
| - nucl_acids (str): the nucleic acid to convert to\n | ||
| Example: nucl_acids = "RNA"\n | ||
| nucl_acids = "DNA"\n | ||
| nucl_acids = "both" | ||
|
|
||
| Return: | ||
| - dict: Dictionary with processed sequences. Depends on desired tool\n | ||
| Please see Readme or desired docstring | ||
| """ |
| @@ -0,0 +1,98 @@ | |||
| def is_gc_in_range(sequence: str, gc_bounds: int or float or tuple(int or float)) -> bool: | |||
| gc_count = ( | ||
| sequence.count("G") | ||
| + sequence.count("C") | ||
| + sequence.count("g") | ||
| + sequence.count("c") | ||
| ) | ||
| gc_percent = gc_count * 100 / len(sequence) |
There was a problem hiding this comment.
С одной строны выглядит красиво, но с друой ты четырежды пробегаешь по строке, которую можно было бы обойти 1 раз. Но тогда да, это нужен был бы просто явный цикл с проверок буквы
| if isinstance(gc_bounds, int) or isinstance(gc_bounds, float): | ||
| gc_bounds = (0, gc_bounds) |
| if isinstance(length_bounds, int): | ||
| length_bounds = (0, length_bounds) | ||
| return length_bounds[0] <= len(sequence) <= length_bounds[1] |
| if __name__ == "__main__": | ||
| import dictionaries | ||
| else: | ||
| from bioinf_modules import dictionaries |
There was a problem hiding this comment.
Хех, ты это из нашего обсуждения или сама нашла? Я не уверен кстати что так принято делать, но я сам не знаю как можно по другому. В любом случае молодец что разобралась с тем как это работает и всякое такое
No description provided.