Development#1
Open
nikavvv57 wants to merge 4 commits into
Open
Conversation
Comment on lines
+5
to
+7
| for nuc in seq: | ||
| if nuc not in dna_nucleotide_alphabet: | ||
| raise ValueError(f"{nuc} this is not a nucleotide in your sequence") |
There was a problem hiding this comment.
Имхо, эта проверка тут лишняя. К тому же в следующих функциях-фильтрах ты её не делаешь.
Такое имеет смысл выносить в отдельную функцию
| @@ -0,0 +1,28 @@ | |||
| dna_nucleotide_alphabet = {'A', 'T', 'G', 'C'} | |||
There was a problem hiding this comment.
Это константа, поэтому капсом (DNA_NUCLEOTIDE_ALPHABET)
Comment on lines
+1
to
+50
| single_letter_alphabet = {'G', 'A', 'V', 'L', 'I', 'M', 'P', 'F', 'W', 'S', 'T', 'N', 'Q', 'Y', 'C', 'K', 'R', 'H', | ||
| 'D', 'E', | ||
| 'g', 'a', 'v', 'l', 'i', 'm', 'p', 'f', 'w', 's', 't', 'n', 'q', 'y', 'c', 'k', 'r', 'h', | ||
| 'd', 'e'} | ||
|
|
||
| three_letter_alphabet = {'GLY', 'ALA', 'VAL', 'LEU', 'ILE', 'MET', 'PRO', 'PHE', 'TRP', 'SER', 'THR', 'ASN', 'GLN', | ||
| 'TYR', 'CYS', 'LYS', 'ARG', 'HIS', 'ASP', 'GLU', | ||
| 'gly', 'ala', 'val', 'leu', 'ile', 'met', 'pro', 'phe', 'trp', 'ser', 'thr', 'asn', 'gln', | ||
| 'tyr', 'cys', 'lys', 'arg', 'his', 'asp', 'glu', | ||
| } | ||
|
|
||
| amino_acid_weights = { | ||
| 'A': 89, 'R': 174, 'N': 132, 'D': 133, 'C': 121, | ||
| 'E': 147, 'Q': 146, 'G': 75, 'H': 155, 'I': 131, | ||
| 'L': 131, 'K': 146, 'M': 149, 'F': 165, 'P': 115, | ||
| 'S': 105, 'T': 119, 'W': 204, 'Y': 181, 'V': 117 | ||
| } | ||
|
|
||
| most_frequent_codon_for_amino_acid_e_coli = { | ||
| 'A': 'GCT', 'R': 'CGT', 'N': 'AAC', 'D': 'GAC', 'C': 'TGC', | ||
| 'E': 'GAA', 'Q': 'CAG', 'G': 'GGC', 'H': 'CAC', 'I': 'ATC', | ||
| 'L': 'CTG', 'K': 'AAA', 'M': 'ATG', 'F': 'TTC', 'P': 'CCG', | ||
| 'S': 'TCT', 'T': 'ACC', 'W': 'TGG', 'Y': 'TAC', 'V': 'GTT', | ||
| 'a': 'gct', 'r': 'cgt', 'n': 'aac', 'd': 'gac', 'c': 'tgc', | ||
| 'e': 'gaa', 'q': 'cag', 'g': 'ggc', 'h': 'cac', 'i': 'atc', | ||
| 'l': 'ctg', 'k': 'aaa', 'm': 'atg', 'f': 'ttc', 'p': 'ccg', | ||
| 's': 'tct', 't': 'acc', 'w': 'tgg', 'y': 'tac', 'v': 'gtt' | ||
| } | ||
| dict_charge_acid = { | ||
| 'negative_charge': ['E', 'D', 'e', 'd'], | ||
| 'positive_charge': ['K', 'R', 'H', 'k', 'r', 'h'], | ||
| 'neutral_charge': ['V', 'W', 'P', 'w', 'v', 'p', 'i', 'F', 'f', 'm', 'A', | ||
| 'a', 'L', 'M', 'l', 'I', 'S', 's', 'T', 't', 'N', 'n', | ||
| 'Q', 'q', 'C', 'c', 'Y', 'y', 'G', 'g']} | ||
|
|
||
| dict_class_acid = { | ||
| 'hydrophilic': ['t', 'q', 'r', 's', 'y', 'd', 'e', 'g', | ||
| 'c', 'n', 'h', 'k', 'T', 'Q', 'R', 'S', | ||
| 'Y', 'D', 'E', 'G', 'C', 'N', 'H', 'K'], | ||
| 'hydrophobic': ['V', 'W', 'P', 'w', 'v', 'p', 'i', 'F', | ||
| 'f', 'm', 'A', 'a', 'L', 'M', 'l', 'I']} | ||
|
|
||
| aminoacid_dict = { | ||
| 'GLY': 'G', 'ALA': 'A', 'VAL': 'V', 'LEU': 'L', 'ILE': 'I', 'MET': 'M', | ||
| 'PRO': 'P', 'PHE': 'F', 'TRP': 'W', 'SER': 'S', 'THR': 'T', 'ASN': 'N', 'GLN': 'Q', | ||
| 'TYR': 'Y', 'CYS': 'C', 'LYS': 'K', 'ARG': 'R', 'HIS': 'H', 'ASP': 'D', 'GLU': 'E', | ||
| 'gly': 'g', 'ala': 'a', 'val': 'v', 'leu': 'l', 'ile': 'i', 'met': 'm', | ||
| 'pro': 'p', 'phe': 'f', 'trp': 'w', 'ser': 's', 'thr': 't', 'asn': 'n', 'gln': 'q', | ||
| 'tyr': 'y', 'cys': 'c', 'lys': 'k', 'arg': 'r', 'his': 'h', 'asp': 'd', 'glu': 'e', | ||
| } |
There was a problem hiding this comment.
Это всё константы, поэтому нужно капсом
| :return: int | ||
| """ | ||
| sequence_upper = sequence.upper() | ||
| molecular_weight = sum(amino_acid_weights.get(aa, 0) for aa in sequence_upper) |
Comment on lines
+121
to
+130
| if percent: | ||
| result_dict = {"Percentage of positive charged amino acids": (round((amount_positive * 100) / len(amino_seq))), | ||
| "Percentage of neutrally charged amino acids": | ||
| (round((amount_neutral * 100) / len(amino_seq))), | ||
| "Percentage of negative charged amino acids": | ||
| (round((amount_negative * 100) / len(amino_seq)))} | ||
| else: | ||
| result_dict = {"Positive charged amino acids": amount_positive, | ||
| "Neutrally charged amino acids": amount_neutral, | ||
| "Negative charged amino acids": amount_negative} |
There was a problem hiding this comment.
Не оч хорошо, что возвращается словарь с разными ключами. Ты же скорее всего эту функцию будешь вызывать не только для отображения. Соответственно, в другой функции тебе нужно будет доставать значение по ключу
| return gc_content_percent | ||
|
|
||
|
|
||
| def transcribe(sequence): |
| return rna_seq | ||
|
|
||
|
|
||
| def reverse(sequence): |
| return sequence[::-1] | ||
|
|
||
|
|
||
| def complement(sequence): |
| return complement_seq | ||
|
|
||
|
|
||
| def reverse_complement(sequence): |
Comment on lines
+57
to
+58
| dna_nucleotide_alphabet = {'A', 'T', 'G', 'C', 'a', 't', 'g', 'c'} | ||
| rna_nucleotide_alphabet = {'A', 'U', 'G', 'C', 'a', 'u', 'g', 'c'} |
There was a problem hiding this comment.
Константы ))
Нужно капсом + перенести наверх
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
modules, readme, main script for modules