-
Notifications
You must be signed in to change notification settings - Fork 0
Hw5 lukina #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
Open
MariaLuk
wants to merge
4
commits into
main
Choose a base branch
from
HW5_lukina
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hw5 lukina #1
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,196 @@ | ||
| # Junior_Bioinformatic_tool | ||
| # My junior biochemical tool | ||
| This package for junior bioinformaticians is designed to work with nucleotide and amino acid sequences and FASTQ files, and consists of three parts. Each module `amino_acid_tools`, `dna_rna_tools` and `fastq_filtration` presents its own possibilities for sequence processing. | ||
|
|
||
| # `amino_acids_tools` | ||
| This tool is designed to work with amino acid sequences consisting of _22 proteinogenic amino acid_ residues (including pyrrolizine and selenocysteine) recorded in a standard one-letter format. It is not intended to process sequences with post-translational and other amino acid modifications | ||
|
|
||
| ## Usage | ||
| You call the `amino_acid_tools` function, which takes as input an arbitrary number of arguments with amino-acid sequences (str), as well as the name of the procedure to be executed (it is always the last argument, str). After that the command performs the specified action on all the given sequences. If one sequence is submitted, a string with the result is returned. If several sequences are submitted, a list of strings is returned. | ||
| Input sequences can contain both uppercase and lowercase letters, but the last argument with the function name must correspond to the listed functions. | ||
|
|
||
|
|
||
| ## Options | ||
| The following options for aminoacid sequence processing are available at the moment: | ||
|
|
||
| - **molecular_weight**: calculate the molecular weight of the amino acid chain in Da, according to the average amino acid residues molecular masses rounded to 1 or 2 decimal places. | ||
| - **three_letter_code**: converts standard single letter translations to three letter translations | ||
| - **show_length**: count the overall number of amino acids in the given | ||
| - **sequence folding**: count the number of amino acids characteristic separately for alpha helixes and beta sheets,and give out what will be the structure of the protein more. This function has been tested on proteins such as 2M3X, 6DT4 (PDB ID) and MHC, CRP. The obtained results corresponded to reality. | ||
| - **seq_charge**: evaluates the overall charge of the aminoacid chain in neutral aqueous solution (pH = 7), according to the pKa of amino acid side chains, lysine, pyrrolizine and arginine contribute +1, while asparagine and glutamic amino acids contribute -1. The total charge of a protein is evaluated as positive, negative, or neutral as the sum of these contributions | ||
|
|
||
| ### Remarks | ||
| If sequense contains symbols differ from IUPAC 1-letter code for 22 proteinogenic amino acids, | ||
| the result *for this sequence* will be `'unexpected symbols in sequence'` regardless of function | ||
| If action is not in the function the message `'unexpected action'` will occur | ||
|
|
||
| ## Examples | ||
| Below is an example of processing an amino acid sequence for different input data | ||
| ```Python | ||
| amino_acid_tools('DNA', 'molecular_weight') | ||
| ``` | ||
| Output: 300.28 | ||
|
|
||
| ```Python | ||
| amino_acid_tools('DNA', 'russco', 'LOLkEk', 'azaz', 'three_letter_code') | ||
| ``` | ||
| Output: ['AspAsnAla', 'ArgSecSerSerCysPyl', 'LeuPylLeuLysGluLys', 'unexpected symbols in sequence'] | ||
|
|
||
| ```Python | ||
| amino_acid_tools('DNA', 'russco', 'LOLkEk', 'azaz', 'letter_code') | ||
| ``` | ||
| ValueError: Unexpected action | ||
|
|
||
| ### Using the function for molecular weight calculation | ||
|
|
||
| ```Python | ||
| amino_acid_tools('EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'molecular_weight') | ||
| ``` | ||
|
|
||
| Input: 'EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'molecular_weight' | ||
| Output: '[1228.66, 1447.8400000000001, 1224.6399999999999]' | ||
|
|
||
| ### Using the function to convert one-letter translations to three-letter translations | ||
|
|
||
| ```Python | ||
| amino_acid_tools('EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'three_letter_code') | ||
| ``` | ||
|
|
||
| Input: 'EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'three_letter_code' | ||
| Output: '['GluGlyValIleMetSerGluLeuLysLeuLys', 'ProLeuProLysValGluLeuProProAspPheValAsp', 'AspValIleGlyIleSerIleLeuGlyLysGluVal']' | ||
|
|
||
| ### Using the function to counts the number of amino acids in the given sequence | ||
|
|
||
| ```Python | ||
| amino_acid_tools('EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'show_length') | ||
| ``` | ||
|
|
||
| Input: 'EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'show_length' | ||
| Output: '[11, 13, 12]' | ||
|
|
||
| ### Using the function to determine the predominant secondary structure | ||
|
|
||
| ```Python | ||
| amino_acid_tools('EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'folding') | ||
| ``` | ||
| Input: 'EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'folding' | ||
| Output: '['alfa_helix', 'equally', 'equally']' | ||
|
|
||
| ### Using the function to estimate relative charge | ||
|
|
||
| ```Python | ||
| amino_acid_tools('EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'seq_charge') | ||
| ``` | ||
|
|
||
| Input: 'EGVIMSELKLK', 'PLPKvelPPDFVD', 'DVIGISILGKEV', 'seq_charge' | ||
| Output: '['neutral', 'negative', 'negative']' | ||
|
|
||
| # `DNA_RNA_tools` | ||
|
|
||
| This program is designed to work with nucleic acid sequences. We expect RNA and DNA chains in the standard NNNNNNNN form, without phosphate groups, in uppercase or lowercase letters | ||
|
|
||
| ### Usage | ||
| You call the `dna_rna_tools` function, which takes as input anumber of arguments with amino-acid sequences (str), as well as the name of the procedure to be executed (it is always the last argument, str). | ||
|
|
||
| The nucleotide sequence can consist of both uppercase and lowercase letters. | ||
| Input example: | ||
| ```Python | ||
| dna_rna_tools('GCGGT','auccuc','GCTatGc','complement') | ||
| ``` | ||
|
|
||
| ### Functions: | ||
| Folowing options are avaliable now: | ||
|
|
||
| - **complement:** makes complement sequence to seq | ||
| - **reverse**: reverses sequence, (from 5'-3' to 3' -5' there or back) | ||
| - **reverse_complement**: makes complement sequence and reverse it | ||
| - **transcribe**: make transcript of DNA sequence. in the case of RNA | ||
| sequence, no changes will be returned | ||
|
|
||
| *Returns:* | ||
| If one sequence is supplied, a string with the result is returned. | ||
| If several are submitted, a list of strings is returned. | ||
|
|
||
| #### Remarks | ||
| If seq contains both U(u) and T(t) the result *for this sequence* will be `"U and T in one seq"` regardless of function | ||
|
|
||
| If seq contains symbols differ from standardized oligonucleotide notation, the result *for this sequence* will be `'unexpected symbols in sequence'` regardless of function | ||
| If action is not in the function the message `'unexpected action'` will occur | ||
|
|
||
| ### Examples: | ||
| ```Python | ||
| dna_rna_tools('ATTC', 'CGcGc', 'AZA', 'atuc', 'Au', 'transcribe') | ||
| ``` | ||
| Output: ['AUUC', 'CGcGc', 'unexpected symbols in sequence', 'T and U in one seq', 'Au'] | ||
|
|
||
|
|
||
| ```Python | ||
| dna_rna_tools('ATTC', 'CGcGc', 'AZA', 'atuc', 'Au', 'revese') | ||
| ``` | ||
| ValueError: Unexpected action | ||
|
|
||
| ```Python | ||
| dna_rna_tools('UuCG','complement') | ||
| ``` | ||
| Output: 'AaGC' | ||
|
|
||
| # `FASTQ_filtration tool` | ||
|
|
||
| This function provides you the opportunity to filter the FASTQ list to select sequences according to requirements on three parameters: length, GC composition, and quality of the reed | ||
|
|
||
| ### Usage | ||
| It is required to input the list of sequences in dictionary format, as well as values for filtering parameters: interval by GC-composition, interval by sequence length, threshold value of average quality of reed | ||
| Input example: | ||
| ```Python | ||
| fastq_filtration(seqs, gc_bounds=(20, 40), length_bounds=(0, 2 *8), quality_treshold=10) | ||
| ``` | ||
|
|
||
| #### Filtering parameters | ||
|
|
||
| - seqs: dictionary of FASTQ sequences *{name: (sequence, quality)}* | ||
| - **gc_bounds:** interval for the of acceptable GC content, in %, *Default | ||
| value = (0,100)* | ||
| - **length_bounds**: interval for the of acceptable sequense length in | ||
| number of nucleotide, *Default value = (2,2**32)* | ||
| - **quality_treshold**: threshold value for average quality per nucleotide | ||
| (phred33 scale), *Default value = 0* | ||
|
|
||
|
|
||
| ### Result: | ||
| New dictionary consists of selected sequences after 3-step filtration | ||
| #### Remarks | ||
| After running without specifying the filtering parameters, all sequences will be be selected as appropriate | ||
| You also can specify only the upper limit for GC-content and length filtering | ||
|
|
||
| ### Examples | ||
|
|
||
| ```Python | ||
| d = {'a': ('atcaaa', '@@@@@@'), 'b': ('gcc', '@@!'), 'c': ('ga', '!!'), 'd': ('ga', '@@')} | ||
| ``` | ||
| ```Python | ||
| fastq_filtration(d) | ||
| ``` | ||
| Output: {'a': ('atcaaa', '@@@@@@'), 'b': ('gcc', '@@!'), 'c': ('ga', '!!'), 'd': ('ga', '@@')} | ||
| No filtration with default values | ||
|
|
||
| ```Python | ||
| fastq_filtration(d, 40, (0, 3), 10) | ||
| ``` | ||
| Output: {} | ||
|
|
||
| ```Python | ||
| fastq_filtration(d, 50, (0, 7), 10) | ||
| ``` | ||
| Output: {'a': ('atcaaa', '@@@@@@'), 'd': ('ga', '@@')} | ||
|
|
||
| ```Python | ||
| fastq_filtration(d, 50, (0, 7), 0) | ||
| ``` | ||
| Output: {'a': ('atcaaa', '@@@@@@'), 'c': ('ga', '!!'), 'd': ('ga', '@@')} | ||
|
|
||
|
|
||
| ##### Contacts | ||
| Maria Lukina | ||
| maria.v.luk@gmail.com | ||
|
|
||
|
|
||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| NAMES = {'A': 'Ala', 'R': 'Arg', 'N': 'Asn', 'D': 'Asp', 'C': 'Cys', 'E': 'Glu', 'Q': 'Gln', 'G': 'Gly', 'H': 'His', | ||
| 'I': 'Ile', 'L': 'Leu', 'K': 'Lys', 'M': 'Met', 'F': 'Phe', 'P': 'Pro', 'S': 'Ser', 'T': 'Thr', 'W': 'Trp', | ||
| 'Y': 'Tyr', 'V': 'Val', 'U': 'Sec', 'O': 'Pyl', 'a': 'Ala', 'r': 'Arg', 'n': 'Asn', 'd': 'Asp', 'c': 'Cys', | ||
| 'e': 'Glu', 'q': 'Gln', 'g': 'Gly', 'h': 'His', 'i': 'Ile', 'l': 'Leu', 'k': 'Lys', 'm': 'Met', 'f': 'Phe', | ||
| 'p': 'Pro', 's': 'Ser', 't': 'Thr', 'w': 'Trp', 'y': 'Tyr', 'v': 'Val', 'u': 'Sec', 'o': 'Pyl'} | ||
| MASSES = {'A': 71.08, 'R': 156.2, 'N': 114.1, 'D': 115.1, 'C': 103.1, 'E': 129.1, 'Q': 128.1, 'G': 57.05, 'H': 137.1, | ||
| 'I': 113.2, 'L': 113.2, 'K': 128.2, 'M': 131.2, 'F': 147.2, 'P': 97.12, 'S': 87.08, 'T': 101.1, 'W': 186.2, | ||
| 'Y': 163.2, 'V': 99.13, 'U': 168.05, 'O': 255.3, 'a': 71.08, 'r': 156.2, 'n': 114.1, 'd': 115.1, 'c': 103.1, | ||
| 'e': 129.1, 'q': 128.1, 'g': 57.05, 'h': 137.1, 'i': 113.2, 'l': 113.2, 'k': 128.2, 'm': 131.2, 'f': 147.2, | ||
| 'p': 97.12, 's': 87.08, 't': 101.1, 'w': 186.2, 'y': 163.2, 'v': 99.13, 'u': 168.05, 'o': 255.3} | ||
|
|
||
|
|
||
| def molecular_weight(seq: str) -> float: | ||
| """ | ||
| Function calculates molecular weight of the amino acid chain | ||
| Parameters: | ||
| seq (str): each letter refers to one-letter coded proteinogenic amino acids | ||
| Returns: | ||
| (float) Molecular weight of tge given amino acid chain in Da | ||
| """ | ||
| m = 0 | ||
| for acid in seq: | ||
| m += MASSES[acid] | ||
| return m | ||
|
|
||
|
|
||
| def three_letter_code(seq: str) -> str: | ||
| """ | ||
| Function converts single letter translations to three letter translations | ||
| Parameters: | ||
| seq (str): each letter refers to one-letter coded proteinogenic amino acids | ||
| Returns: | ||
| (str) translated in three-letter code | ||
| """ | ||
| recording = seq.maketrans(NAMES) | ||
| return seq.translate(recording) | ||
|
|
||
|
|
||
| def length(seq: str) -> int: | ||
| """ | ||
| Function counts the number of amino acids in the given sequence | ||
| Parameters: | ||
| seq (str): amino acid sequence | ||
| Returns: | ||
| (int): integer number of amino acid residues | ||
| """ | ||
| return len(seq) | ||
|
|
||
|
|
||
| def folding(seq: str) -> str: | ||
| """ | ||
| Counts the number of amino acids characteristic separately for alpha helixes and beta sheets, | ||
| and gives out what will be the structure of the protein more. | ||
| This function has been tested on proteins such as 2M3X, 6DT4 (PDB ID) and MHC, CRP. | ||
| The obtained results corresponded to reality. | ||
| Parameters: | ||
| seq (str): amino acid sequence | ||
| Returns: | ||
| (str): overcoming structure ('alfa_helix', 'beta_sheet', 'equally') | ||
| """ | ||
| alfa_helix = ['A', 'E', 'L', 'M', 'G', 'Y', 'S', 'a', 'e', 'l', 'm', 'g', 'y', 's'] | ||
| beta_sheet = ['Y', 'F', 'W', 'T', 'V', 'I', 'y', 'f', 'w', 't', 'v', 'i'] | ||
| alfa_helix_counts = 0 | ||
| beta_sheet_counts = 0 | ||
| for amino_acid in seq: | ||
| if amino_acid in alfa_helix: | ||
| alfa_helix_counts += 1 | ||
| elif amino_acid in beta_sheet: | ||
| beta_sheet_counts += 1 | ||
| if alfa_helix_counts > beta_sheet_counts: | ||
| return 'alfa_helix' | ||
| elif alfa_helix_counts < beta_sheet_counts: | ||
| return 'beta_sheet' | ||
| elif alfa_helix_counts == beta_sheet_counts: | ||
| return 'equally' | ||
|
|
||
|
|
||
| def seq_charge(seq: str) -> str: | ||
| """ | ||
| Function evaluates the overall charge of the aminoacid chain in neutral aqueous solution (pH = 7) | ||
| Parameters: | ||
| seq (str): amino acid sequence of proteinogenic amino acids | ||
| Returns: | ||
| (str): "positive", "negative" or "neutral" | ||
| """ | ||
| aminoacid_charge = {'R': 1, 'D': -1, 'E': -1, 'K': 1, 'O': 1, 'r': 1, 'd': -1, 'e': -1, 'k': 1, 'o': 1} | ||
| charge = 0 | ||
| for aminoacid in seq: | ||
| if aminoacid in aminoacid_charge.keys(): | ||
| charge += aminoacid_charge[aminoacid] | ||
| if charge > 0: | ||
| return 'positive' | ||
| elif charge < 0: | ||
| return 'negative' | ||
| else: | ||
| return 'neutral' |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| def gc_content(seq: str) -> float: | ||
| """ | ||
| Supporting function | ||
| Function counts GC-content in sequence, and returns result in % | ||
| Parameters: | ||
| seq (str): oligo- and polynucleotide sequence | ||
| Returns: | ||
| (float): % of GC-content | ||
| """ | ||
| n = 0 | ||
| for nucl in seq: | ||
| if nucl == 'c' or nucl == 'g' or nucl == 'C' or nucl == 'G': | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. А можно просто .upper() |
||
| n += 1 | ||
| return 100 * n / len(seq) | ||
|
|
||
|
|
||
| def filter_gc(seqs: dict, gc_bounds_both_side=(0, 100)) -> dict: | ||
| """ | ||
| This function selects sequences with the GC content of your interest | ||
| :parameters: | ||
| seqs: dictionary of FASTQ sequences {name: (sequence, quality)} | ||
| gc_bound: interval for the of acceptable GC content, in % | ||
| :return:(dict) new dictionary consists of selected sequences | ||
| """ | ||
| d_new = {} | ||
| for key, params in seqs.items(): | ||
| if gc_bounds_both_side[1] >= gc_content(params[0]) >= gc_bounds_both_side[0]: | ||
| d_new[key] = (params[0], params[1]) | ||
| return d_new | ||
|
|
||
|
|
||
| def filter_length(seqs: dict, length_bounds_both_side=(0, 2 ** 32)) -> dict: | ||
| """ | ||
| This function selects sequences with the length of your interest | ||
| :parameters: | ||
| seqs: dictionary of FASTQ sequences {name: (sequence, quality)} | ||
| length_bound: interval for the of acceptable sequense length in number of nucleotide | ||
| :return:(dict) new dictionary consists of selected sequences | ||
| """ | ||
| d_new = {} | ||
| for key, params in seqs.items(): | ||
| if length_bounds_both_side[1] >= len(params[0]) >= length_bounds_both_side[0]: | ||
| d_new[key] = (params[0], params[1]) | ||
| return d_new | ||
|
|
||
|
|
||
| def filter_quality(seqs: dict, quality_treshold=0) -> dict: | ||
| """ | ||
| This function selects FASTQ sequences with appropriate average nucleotide read quality | ||
| parameters: | ||
| seqs: dictionary of FASTQ sequences {name: (sequence, quality)} | ||
| quality_treshold: threshold value for average quality per nucleotide (phred33 scale) | ||
| :return:(dict) new dictionary consists of selected sequences | ||
| """ | ||
| d_new = {} | ||
| for key, params in seqs.items(): | ||
| quality_sum = 0 | ||
| for n in params[1]: | ||
| quality_sum += ord(n) - 33 | ||
| if quality_sum / len(params[1]) >= quality_treshold: | ||
| d_new[key] = (params[0], params[1]) | ||
| return d_new | ||
Oops, something went wrong.
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.
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.
)))0)0
Хотя всё-таки в "официальной документации" так делать не надо ))