jbioseqtools 2.1.4
jbioseqtools
License: MIT
Requires Python: <3.11,>=3.8
Keywords: sequence, optimization, vectors, AAV, GC, restriction enzyme, therapies, design, genetic

# JBioSeqTools - python library

#### JBioSeqTools is the Python library for gene sequence downloading, optimization, structure prediction, vector building, and visualization


<p align="right">
<img  src="https://github.com/jkubis96/Logos/blob/main/logos/jbs_current.png?raw=true" alt="drawing" width="200" />
</p>


### Author: Jakub Kubiś 

<div align="left">
 Institute of Bioorganic Chemistry<br />
 Polish Academy of Sciences<br />
</div>


## Description


<div align="justify"> JBioSeqTools is the Python library for biological sequence optimization (GC % content & codon frequency), restriction places removal, DNA/RNA structure prediction, and RNAi selection. It also allows the building of many plasmid vectors with the possibility of choosing sequences such as transcript, promoter, enhancer, molecular fluorescent tag, etc. Finally, the user obtains a ready-for-order construct with a whole sequence and visualization.
</div>

</br>

Used databases:
* [GeneScript](https://www.genscript.com/?src=google&gclid=Cj0KCQiAkMGcBhCSARIsAIW6d0CGxHmZO8EAYVQSwgk5e3YSRhKZ882vnylGUxfWuhareHFkJP4h4rgaAvTNEALw_wcB)
* [VectorBuilder](https://en.vectorbuilder.com/)
* [UTRdb](https://utrdb.cloud.ba.infn.it/utrdb/index_107.html)
* [NCBI refseq_select_rna](ftp.ncbi.nlm.nih.gov)

<br />

<br />

## Table of contents

[Installation](#installation) \
[Usage](#usage)
1. [seq_tools - part of the library containing sequence optimization, structure prediction, and visualization](#seq_tools) \
1.1. [Import part of library](#import-seq_tools) \
1.2. [Loading metadata](#loading-metadata) \
1.3. [Downloading reference sequences with gene name](#downloading-ref) \
1.4. [Downloading  sequences with accession numbers](#downloading-accession) \
1.5. [Creating FASTA format *.FASTA](#creating-fasta) \
1.6. [Loading FASTA format from file *.FASTA](#loading-fasta) \
1.7. [Writing to FASTA format *.FASTA](#writing-fasta) \
1.8. [Conducting Multiple Alignments Analysis (MUSCLE) form FASTA](#muscle) \
1.9. [Display alignment plot](#alignment-plot) \
1.10. [Decoding alignment file](#decoding-alignment) \
1.11. [Writing to ALIGN format *.ALIGN](#writing-align) \
1.12. [Extracting consensus parts of alignments](#extracting-consensuse) \
1.13. [Passing sequence from an external source](#passing-sequence) \
1.14. [Clearing junk characters from the sequence](#clearing-sequence) \
1.15. [Checking that the sequence is coding protein (CDS)](#checking-cds) \
1.16. [Checking that all bases in sequence are contained in the UPAC code](#checking-upac) \
1.17. [Reversing the DNA / RNA sequence: 5' --> 3' and 3' --> 5'](#reversing) \
1.18. [Complementing the DNA / RNA second strand sequence](#complementing) \
1.19. [Changing DNA to RNA sequence](#dna-rna) \
1.20. [Changing RNA to DNA sequence](#rna-dna) \
1.21. [Changing DNA or RNA sequence to amino acid / protein sequence](#dna-protein) \
1.22. [Prediction of RNA / DNA sequence secondary structure](#prediction) \
1.23. [Prediction of RNAi on the provided sequence](#rnai-prediction) \
1.24. [Correcting of RNAi_data for complementarity to the loop sequence](#correcting-loop) \
1.25. [Correcting of RNAi_data for complementarity to the additional external sequence](#correcting-sequence) \
1.26. [Codon optimization](#optimize) \
1.27. [Checking susceptibility to restriction enzymes](#resctriction) \
1.28. [Checking and removing susceptibility to restriction enzymes](#resctriction-remove) \
1.29. [Sequence comparison (Interval Fold Change Estimation)](#comp-ifce)
2. [vector_build - part of the library containing building plasmid vectors with optimization elements from seq_tools](#vector-build) \
2.1. [Import part of library](#import-vector_build) \
2.2. [Creating vector plasmid](#creating-vector) \
2.2.1 [Creating expression of the plasmid vector](#expression) \
2.2.2 [Creating RNAi / RNAi + expression of the plasmid vector](#rnai) \
2.2.3 [Creating plasmid vector of in-vitro transcription of mRNA](#transcript-mrna) \
2.2.4 [Creating plasmid vector of in-vitro transcription of RNAi](#transcription-rnai) \
2.3. [Creating sequence for synthesis de novo](#denovo) \
2.3.5 [Creating sequence prediction of mRNA for de novo synthesis](#denovo-mrna) \
2.3.6 [Creating sequence prediction of RNAi for de novo synthesisi](#denovo-rnai) \
2.4. [Creating vector plasmid from FASTA - display existing or custom editing FASTA file](#vector-fasta) \
2.4.1 [Loading fasta from the file](#fasta2-loading) \
2.4.2 [Converting the FASTA string to the data frame](#fasta-df) \
2.4.3 [Decoding FASTA information](#headers) \
2.4.4 [Creating graph of the plasmid vector](#graph) \
2.4.5 [Writing FASTA format of the plasmid vector](#wrfa) \
2.4.6 [Converting FASTA format to GeneBank format](#cvfagb) \
2.4.7 [Writing GeneBank format of the plasmid vector](#wrgb) 




<br />

<br />

# Installation <a id="installation"></a>

#### In command line write:

```
pip install JBioSeqTools
```

* During the first library loading additional requirements will be installed (BLAST, MUSCLE) and metadata downloaded.

<br />

<br />


# Usage <a id="usage"></a>

<br />

### 1. seq_tools - part of the library containing sequence optimization, structure prediction, and visualization <a id="seq_tools"></a>

#### 1.1. Import part of library <a id="import-seq_tools"></a>

```
from jbst import seq_tools as st
```

<br />

#### 1.2. Loading metadata <a id="loading-metadata"></a>

```
metadata = st.load_metadata() 
```

              

    This function loads the metadata from library repository, which includes such elements like: 'codons', 'vectors', 'linkers', 'regulators', 'fluorescent_tag', 'backbone', 'promoters', 'restriction', 'polya_seq', 'selection_markers', 'rnai', 'capacity', 'utr5', 'utr3'.
    These elements are necessary for algorithms, as well as, the database of regulatory genetic sequences for users to project vectors and other genetic therapeutics.
    
    Args:
        
       Some metadata is not necessary for algorithms of plasmid vector creation, such as:

           linkers (bool) - linkers (sequences between coding sequences) and their  description, Default: True
           loops (bool) - loops (sequences for creating shRNA / siRNA) and their  description, Default: True
           regulators (bool) - regulators (regulatory sequence elements for expression enhancement) and their  description, Default: True
           fluorescent_tag (bool) - fluorescent_tag (sequences coding fluorescent proteins) and their  description, Default: True 
           promoters (bool) - promoters (previously described promoter sequences for providing coding and non-coding sequence transcription) and their  description, Default: True
           polya (bool) - signal of polyadenylation sequences and their description, Default: True
           marker (bool) - selection marker sequences for bacterial selection by resistance to antibiotics and their description, Default: True
           utr5 (bool) - 5`UTR sequences and their  description, Default: True
           utr3 (bool) - 3`UTR sequences and their  description, Default: True
       
      If the user uses external sources for providing these sequences and names, it can be set to False and these metadata will not load and reduce RAM usage.        
          
    Returns:
        dict: Dictionary with the crucial set of metadata


<br />

#### 1.3. Downloading reference sequences with gene name <a id="downloading-ref"></a>

```
data_dict = st.get_sequences_gene(gene_name, species = 'human', max_results = 20)
```

 
    This function gets sequences from NCBI database based on gene name & species
        
    Args:
        gene_name (str) - name of searching gene in the HGNC nomenclature
        species (str) - specie for which the gene sequence is searching (human / mouse / rat / both* / both2* / multi* / other**). Default: 'human'
       
            *both - gene sequences for Mus musculus and Homo sapiens
            *both2 - gene sequences for Rattus norvegicus and Homo sapiens
            *multi - gene sequences for Mus musculus, Rattus norvegicus, and Homo sapiens
       
            **other - the user can provide any species in Latin language via binomial nomenclature eg. Bos taurus, Zea mays, Sus scrofa, Danio rerio, Oryza sativa ...
       
        max_results (int) - number of maximal amount of results for the provided gene and species. Default: 20
        input_dict (dict) - dictionary of metadata provided by the user

    Returns:
        dict: Dictionary including all sequence variants, their names, features, and IDs of provided gene
       
    

<br />

#### 1.4. Downloading  sequences with accession numbers <a id="downloading-accession"></a>

```
data_dict = st.get_sequences_accesion(accesion_list)
```
 
    This function gets sequences from NCBI database based on accession numbers
        
    Args:
       accesion_list (list) - accession numbers or number of searching sequences inside list eg. ['X81403.1', 'KJ890665.1']; ['KJ890665.1']
       

    Returns:
        dict: Dictionary including all sequences from the provided query, their names, features, and IDs
       
    

<br />

#### 1.5. Creating FASTA format *.FASTA <a id="creating-fasta"></a>

```
fasta_string = st.generate_fasta_string(data_dict)
```

    
    This function trnasform dictionaries from get_sequences_accesion() or get_sequences_gene() into FASTA format.
        
    Args:
       data_dict (dict) - dictionaries from get_sequences_accesion() or get_sequences_gene()
       

    Returns:
        txt: FASTA format of input dictionary
       


<br />

#### 1.6. Loading FASTA format from file *.FASTA <a id="loading-fasta"></a>

```
fasta_string = st.load_fasta(path)
```

    
    This function finds and removes restriction places inside the sequence.    
    
    Args:
       path (str) - path to the FASTA file *.FASTA
       

    Returns:
        str: Loaded FASTA file to the string object
       
    

<br />

#### 1.7. Writing to FASTA format *.FASTA <a id="writing-fasta"></a>

```
st.write_fasta(fasta_string, path = None, name = 'fasta_file')
```

    
    This function saves into FASTA *.fasta
    
    Args:
        fasta_string (str/FASTA) - sequences provided in FASTA format from generate_fasta_string() or loaded from external sources
        path (str | None) - the path to save. If None save it to the current working directory. Default: None
        name (str) - the name of the saving file. Default: 'fasta_file'



<br />


#### 1.8. Conducting Multiple Alignments Analysis (MUSCLE) form FASTA <a id="muscle"></a>

```
alignment_file = st.MuscleMultipleSequenceAlignment(fasta_string, output = None, gapopen = 10, gapextend = 0.5)
```

    This function conducts alignments of sequences provided in FASTA format
    
    Args:
       fasta_string (str\FASTA) - sequences provided in FASTA format from generate_fasta_string() or loaded from external sources
       gapopen (int | float) -  description under the link provided below. Default: 10 
       gapextend (int | float) - description under the link provided below. Default:  0.5 
       output (str | None) - path to the TMP alignment file. If None then the current working directory and the TMP file are removed. Default: None 
       
       More information in the source code of the primary function authors:
           - https://www.drive5.com/muscle/

    Returns:
        txt: FASTA format of input dictionary
       

<br />

#### 1.9. Display alignment plot <a id="alignment-plot"></a>

```
alignment_plot = st.DisplayAlignment(alignment_file, color_scheme="Taylor", wrap_length=80, show_grid=True, show_consensus=True)
alignment_plot.savefig("alignment_plot.svg")
```

    
    This function makes the graphical presentation of the alignments
    
    Args:
       alignment_file (Bio.Align.MultipleSeqAlignment class) - the output file from MuscleMultipleSequenceAlignment()
       color_scheme (str) - color palette for plotting. Default: "Taylor"
       wrap_length (int) - max number of nucleotides shown in a row on the graph. Default: 80 
       show_grid (bool) - show the grid on the graph. Default: True
       show_consensus (bool) - highlight the consensus sequences. Default: True
       
       More information in the source code of the primary function authors:
           - https://pypi.org/project/pyMSAviz/

    Returns:
        graph: The graphical presentation of sequences alignments
               
       
    
<br />

##### Example of the alignment graph:

<p align="center">
<img  src="https://github.com/jkubis96/JBioSeqTools/blob/v.2/fig/alignments.jpg?raw=true" alt="drawing" width="700" />
</p>




<br />

#### 1.10. Decoding alignment file <a id="decoding-alignment"></a>

```
decoded_alignment_file = st.decode_alignments(alignment_file)
```

    
    This function decodes the alignment file from MuscleMultipleSequenceAlignment() and converts it to FASTA-ALIGNMENT
    
    Args:
       alignment_file (Bio.Align.MultipleSeqAlignment class) - the output file from MuscleMultipleSequenceAlignment()
      

    Returns:
        txt: FASTA-ALIGNMENT format of input file
       

<br />


##### Example output:

```
print(decoded_alignment_file)

Homo_sapiens_survival_of_motor_neuron_1,_telomeric_(SMN1),_transcript_variant_b,_mRNA | -CCACAAATGTGGGAGGGCGATAACCACTCGTAG-AAAGCGTGAGAAGTTACTACAAGC-G-G-TCCTCCC--G-GCCACCG-TACT-G-TT-C--C-----GCTCC-C-AGAAGCC--C--CGGGCGGCGG-AAGTCGTCACTCTTAAGAAGGGACGGGGCCCCACGCTG-CGCACCCGCGGGT-TTGCTATGGCGATGAGCAGCGG-C-GGCAGTGG-TGGC-G-G-CGTCCCGGAGC-A-G-GAGGATT-CCG-TGCT-G-TTCCGGCGCGGCA-CAGGCCAGAGCGATGATTCTGACATTTGGGATGATACAGCACTGATAAAAGCAT-ATGATAAAGCTGTGGCTT-CATTTAAGCATGCTCTAAAGAATGGTGACATTTGTGAAACTTCGGGTAAACCAAAA-ACCACA-CCTAAAAGAAAACCTGCTAAGAAGAATAAAAGCCAAAAGAAGAATACTGCAGCTTCCTT-ACAACAGTGGAAAGTTGGG-GACAAATGTTCTGCCATTTGGTCAGAAGACGGTTGCATTTACCCAGCTACCATTGC-TTCAATTGATTTTAAGAGAGAAACCTGTGTTGTGGTTTACACTGGATATGGAAATAGAGAGGAGCAAAATC-TGTCCGATCTACTTTCCCCAATCTGTGAAGTAGCTAATAATATAGAACA-AA-ATGCTCAAGAGAATGAAAATGAAAGCCAAGTTT-CAACAGATGAA-AGTGAGA-ACT-C-C-AGGTCTC-CT-GGAAATAAATCAGATA-ACATCAAGCCCAAATCTGCTCCATGGAA-CTC-TTTTCTCCCTCCACCACCCCCC-ATGCCAGGGCCAAGACTGGGACCAGGAAAG--A--T--A-A-TT------C-C--C--C-C-A-C-----C-A-C--C--T---C-C-C--A---T---A---T-G-T--C--C-A-----------G------A-T---T-----C-------T--C---T---T----GA-T--------GATG---CTGATGCTTTGGG-AAGTATGTTAATTTCAT-GGTACATGAGTGGCTATCATACTGGCTATTATATGGGTTTCAGACAAAATCAAAAAGAAGGAAGGTGCTCACATTCCTTAAATTAAGG-AGAAATGCTGGCATAGAGCAGCACTAAATGAC-ACCACTAAAGAAACGAT-CAGAC-A-GATCT--GGA-ATGTGAAGCGTTATAGAAGATAACTGGCCTCATTTCTTCAAAATATCAAGTGTTGGGA-AAGAAAAAAGGA-AGTGGAATGGGTAACTCTTCTTGATTAAAAGTTATGTAATAAC-CAAAT-G-C-AATGTGAAATATTTTACTGGACTCTATTTTGAAAAACCATCTGTAAAAGAC-TGGGG-TGGGGGTGGGAGGCCAGCACGGTGGTGAGGCAGTTGAGAAAATTTGAATGTGGATTAG-ATTTTG-AATGATATTG-GATAATTATTGGTAATTTTATGAGCTGTGAG-AAGGGTGTTGTAGTTTATAAAAGACTGTCTTAATTTGCATACTTAAGCATTTAGGAATGAAGTGTTAGAGTGTCTTA-AAATGTTTCAAATGGTTTAA--CAAAATGTATGTGAGGCGTATGTGGCA-AAATGTTACAGAATCTAACTGGTGGACATGGCTGTTCATT-GTACTGTTT----TTTTCTATCTTCTATATG--TTTAAAAGTATATAATAAAAATATTTAATTTTTTTTTAAAAAAAAAAAAAAAAA----AA
Homo_sapiens_survival_of_motor_neuron_1,_telomeric_(SMN1),_transcript_variant_d,_mRNA | ----------------G-------C----------A---------------C--C---C-G-----C------G-G-----G-T--T----T----------GCT-----A----------T--G--G-C-G--A-T-G----------------A----G--C-A-G----CG-----GCG-G-----C-A----G-TG-------G-T--G-----G----C-G-G-CGTCCCGGAGC-A-G-GAGGATT-CCG-TGCT-G-TTCCGGCGCGGCA-CAGGCCAGAGCGATGATTCTGACATTTGGGATGATACAGCACTGATAAAAGCAT-ATGATAAAGCTGTGGCTT-CATTTAAGCATGCTCTAAAGAATGGTGACATTTGTGAAACTTCGGGTAAACCAAAA-ACCACA-CCTAAAAGAAAACCTGCTAAGAAGAATAAAAGCCAAAAGAAGAATACTGCAGCTTCCTT-ACAACAGTGGAAAGTTGGG-GACAAATGTTCTGCCATTTGGTCAGAAGACGGTTGCATTTACCCAGCTACCATTGC-TTCAATTGATTTTAAGAGAGAAACCTGTGTTGTGGTTTACACTGGATATGGAAATAGAGAGGAGCAAAATC-TGTCCGATCTACTTTCCCCAATCTGTGAAGTAGCTAATAATATAGAACA-AA-ATGCTCAAGAGAATGAAAATGAAAGCCAAGTTT-CAACAGATGAA-AGTGAGA-ACT-C-C-AGGTCTC-CT-GGAAATAAATCAGATA-ACATCAAGCCCAAATCTGCTCCATGGAA-CTC-TTTTCTCCCTCCACCACCCCCC-ATGCCAGGGCCAAGACTGGGACCAGGAAAGCCAGGTCTAAAATTCAATGGCCCACCACCGCCA-C-CGC-C-ACCACCAC-CACCCCACTTACTAT-C-ATGCTGGCTG-CCTCCATTTC-CTTCTGGACCACCAATAATTCCC-CCA-CCACCTCCCA--TATGT-CCAGA-T-TCTCTT-GATGATGCTGATGCTTTGGG-AAGTATGTTAATTTCAT-GGTACATGAGTGGCTATCATACTGGCTATTATATGGGTTTCAGACAAAATCAAAAAGAAGGAAGGTGCTCACATTCCTTAAATTAAGG-AGAAATGCTGGCATAGAGCAGCACTAAATGAC-ACCACTAAAGAAACGAT-CAGAC-A-GATCT--GGA-ATGTGAAGCGTTATAGAAGATAACTGGCCTCATTTCTTCAAAATATCAAGTGTTGGGA-AAGAAAAAAGGA-AGTGGAATGGGTAACTCTTCTTGATTAAAAGTTATGTAATAAC-CAAAT-G-C-AATGTGAAATATTTTACTGGACTCTATTTTGAAAAACCATCTGTAAAAGAC-TGGGG-TGGGGGTGGGAGGCCAGCACGGTGGTGAGGCAGTTGAGAAAATTTGAATGTGGATTAG-ATTTTG-AATGATATTG-GATAATTATTGGTAATTTTATGAGCTGTGAG-AAGGGTGTTGTAGTTTATAAAAGACTGTCTTAATTTGCATACTTAAGCATTTAGGAATGAAGTGTTAGAGTGTCTTA-AAATGTTTCAAATGGTTTAA--CAAAATGTATGTGAGGCGTATGTGGCA-AAATGTTACAGAATCTAACTGGTGGACATGGCTGTTCATT-GTACTGTTT----TTTTCTATCTTCTATATG--TTTAAAAGTATATAATAAAAATATTTAATTTTTTTTT------------A-A-AT-T-A-
Homo_sapiens_survival_of_motor_neuron_1,_telomeric_(SMN1),_transcript_variant_a,_mRNA | -CCACAAATGTGGGAGGGCGATAACCACTCGTAG-AAAGCGTGAGAAGTTACTACAAGC-G-G-TCCTCCC--G-GCCACCG-TACT-G-TT-C--C-----GCTCC-C-AGAAGCC--C--CGGGCGGCGG-AAGTCGTCACTCTTAAGAAGGGACGGGGCCCCACGCTG-CGCACCCGCGGGT-TTGCTATGGCGATGAGCAGCGG-C-GGCAGTGG-TGGC-G-G-CGTCCCGGAGC-A-G-GAGGATT-CCG-TGCT-G-TTCCGGCGCGGCA-CAGGCCAGAGCGATGATTCTGACATTTGGGATGATACAGCACTGATAAAAGCAT-ATGATAAAGCTGTGGCTT-CATTTAAGCATGCTCTAAAGAATGGTGACATTTGTGAAACTTCGGGTAAACCAAAA-ACCACA-CCTAAAAGAAAACCTGCTAAGAAGAATAAAAGCCAAAAGAAGAATACTGCAGCTTCCTT-ACAACAGTGGAAAGTTGGG-GACAAATGTTCTGCCATTTGGTCAGAAGACGGTTGCATTTACCCAGCTACCATTGC-TTCAATTGATTTTAAGAGAGAAACCTGTGTTGTGGTTTACACTGGATATGGAAATAGAGAGGAGCAAAATC-TGTCCGATCTACTTTCCCCAATCTGTGAAGTAGCTAATAATATAGAACA-AA-ATGCTCAAGAGAATGAAAATGAAAGCCAAGTTT-CAACAGATGAA-AGTGAGA-ACT-C-C-AGGTCTC-CT-GGAAATAAATCAGATA-ACATCAAGCCCAAATCTGCTCCATGGAA-CTC-TTTTCTCCCTCCACCACCCCCC-ATGCCAGGGCCAAGACTGGGACCAGGAAAGCCAGGTCTAAAATTCAATGGCCCACCACCGCCA-C-CGC-C-ACCACCAC-CACCCCACTTACTAT-C-ATGCTGGCTG-CCTCCATTTC-CTTCTGGACCACCAATAATTCCC-CCA-CCACCTCCCA--TATGT-CCAGA-T-TCTCTT-GATGATGCTGATGCTTTGGG-AAGTATGTTAATTTCAT-GGTACATGAGTGGCTATCATACTGGCTATTATAT--G-----GA-A-A-T----------------G---------C------T--GGCAT--A-G--AGC--A--GCA-C--TAAATGAC-ACCACTAAAGAAACGAT-CAGAC-A-GATCT--GGA-ATGTGAAGCGTTATAGAAGATAACTGGCCTCATTTCTTCAAAATATCAAGTGTTGGGA-AAGAAAAAAGGA-AGTGGAATGGGTAACTCTTCTTGATTAAAAGTTATGTAATAAC-CAAAT-G-C-AATGTGAAATATTTTACTGGACTCTATTTTGAAAAACCATCTGTAAAAGAC-TGGGG-TGGGGGTGGGAGGCCAGCACGGTGGTGAGGCAGTTGAGAAAATTTGAATGTGGATTAG-ATTTTG-AATGATATTG-GATAATTATTGGTAATTTTATGAGCTGTGAG-AAGGGTGTTGTAGTTTATAAAAGACTGTCTTAATTTGCATACTTAAGCATTTAGGAATGAAGTGTTAGAGTGTCTTA-AAATGTTTCAAATGGTTTAA--CAAAATGTATGTGAGGCGTATGTGGCA-AAATGTTACAGAATCTAACTGGTGGACATGGCTGTTCATT-GTACTGTTT----TTTTCTATCTTCTATATG--TTTAAAAGTATATAATAAAAATATTTAATTTTTTTTT------------A-A-A------
Mus_musculus_survival_motor_neuron_1_(Smn1),_transcript_variant_2,_mRNA               | G--AC---T-T-----G----TAACT-CTT-TAGCA--G--T--G---TT-CT-C---CTGTATTTCT-TTAAGTG--A--GTTATTAAATTCCTTCTTTATG-TCCTCTA----CCATCATC-A-TG-T-GAAA-T-G-C-TT-TT-A--A---AT-----CC-A-G--GTC-TA-C--C---TTTT-C-A--G-G-TG-----T-GTTAGG-A-T-GCC--CTG-GAC-T---GG-GCGAAGTG-GGA-----G-TGCTGGGTTCT-G-AT-G-A-T-GG-T-GA-TGATGATTCTGACATTTGGGATGATACAGCATTGATAAAAGC-TTATGATAAAGCTGTGGCTTCC-TTTAAGCATGCTCTAAAGAACGGTGACATTTGTGAAACTCCAGATAAGCCAAAAGG-CACAGCC-AGAAGAAAACCTGCCAAGAAGAATAAAAGCCAAAAGAAGAATGCCACAACTCCCTTGA-AACAGTGGAAAGTT-GGTGACAAGTGTTCTGCTGTTTGGTCAGAAGACGGCTGCATTTACCCAGCTACTATTACGTCC-ATTGACTTTAAGAGAGAAACCTGTGTCGTGGTTTATACTGGATATGGAAACAGAGAGGAGCAAAA-CTTATCTGACCTACTTTCCCCGACCTGTGAAGTAGCTAATAGTACAGAACAGAACA--CTC-AG-G-A-G-A-ATGAAAGTCAAGTTTCC-ACAGACG-ACAGTGA-ACACTCCTCCAGA--TCGCTCAGAAGT-AA--AG-CACACAGCAAGTCCAAAGCTGCTCCGTGG-ACCTCAT-TTCTTCCTCCACCA-CCCCCAATGCCAGGGTCAGGATTAGGACCAGGAAAGCCAGGTCTAAAATTCAACGGCCCGCCGCCGCCGCCTC-CACTACC-CC-CTC-CCCC-CTT-CC-TGCCGTGCTGGATGCCC-CCGTT-CCCTTCAGGACCACCAATAA-TCCCGCCACCC-CCTCCCATCT-C-TCCC-GACTGT--C-TGGATGACACTGATGCCCTGGGCA-GTATGCTAATCTC-TTGGTACATGAGTGGCTACCACACTGGCTACTATATGGGTTTCAGACAAAAT-A-A-A--A--AA---G--------------A--A-GG-A-A-A-G-T-GC-T----CA-C----A-T-ACAA--ATT-AAG-AA-G-TTCAG-CTCTG-TCTCAGGAGATG-G--G-G---T----G-T--C-GG--T-G-T-C--C----C-T---G-GTC-G-ACAAG-----A--ACA--G-A-C-G-T--CTC--CTCG-TC---A-TCA-GT-G-GACTC---TTGGCTAA-GTG-G-TG---T-C--G--TC-A-T-C--A-G-C-ATCT-C------CCC---GCT---G-TGGGA-GTC--CA---T--C----CA-TC-------C-T-AA-GT---C-AGCA----GCA--G--A--GCG-T-G-C-CTGG---------G-GC-GTGAGCA--G-T-T-G--G---A-G-G-GAC---C-------G-A--C-C-AG----T-GG-A-G---TG-T-GCGTGTC--GGAAG-G---C--A-G-TCT-ACCC---A-GT-CGTGA--C-T--G-AGCACAAATG-TGCA-A-T-T----G-T---CAT---T-TTC-TTAGCA-TG-TCAAGATTTT-TA---T-TA-ATGCCTTTAGAA-T-TA-AAT-AAAA-G-TC--C-T-TTTTT----------G-A-A-ATCTTG-
Mus_musculus_survival_motor_neuron_1_(Smn1),_transcript_variant_1,_mRNA               | ----------------G----T--C-A-T--T-G-A--G--T--GA-G---C--C---C-G-G---C-----A--G---C-G---------T-C--C-----G-T-------------------G--G-T----A---G-C--------------A--G-G-CC-ATG--G-CG-A-T-G-G-G-----C-A----G-TG-------G-C-GG-A---G----C-GGG-C-TC-C-GAGC-A-G-GAAGA-TAC-GGTGCT-G-TTCCGGCGTGGCACC-GGCCAGAGTGATGATTCTGACATTTGGGATGATACAGCATTGATAAAAGC-TTATGATAAAGCTGTGGCTTCC-TTTAAGCATGCTCTAAAGAACGGTGACATTTGTGAAACTCCAGATAAGCCAAAAGG-CACAGCC-AGAAGAAAACCTGCCAAGAAGAATAAAAGCCAAAAGAAGAATGCCACAACTCCCTTGA-AACAGTGGAAAGTT-GGTGACAAGTGTTCTGCTGTTTGGTCAGAAGACGGCTGCATTTACCCAGCTACTATTACGTCC-ATTGACTTTAAGAGAGAAACCTGTGTCGTGGTTTATACTGGATATGGAAACAGAGAGGAGCAAAA-CTTATCTGACCTACTTTCCCCGACCTGTGAAGTAGCTAATAGTACAGAACAGAACA--CTC-AG-G-A-G-A-ATGAAAGTCAAGTTTCC-ACAGACG-ACAGTGA-ACACTCCTCCAGA--TCGCTCAGAAGT-AA--AG-CACACAGCAAGTCCAAAGCTGCTCCGTGG-ACCTCAT-TTCTTCCTCCACCA-CCCCCAATGCCAGGGTCAGGATTAGGACCAGGAAAGCCAGGTCTAAAATTCAACGGCCCGCCGCCGCCGCCTC-CACTACC-CC-CTC-CCCC-CTT-CC-TGCCGTGCTGGATGCCC-CCGTT-CCCTTCAGGACCACCAATAA-TCCCGCCACCC-CCTCCCATCT-C-TCCC-GACTGT--C-TGGATGACACTGATGCCCTGGGCA-GTATGCTAATCTC-TTGGTACATGAGTGGCTACCACACTGGCTACTATATGGGTTTCAGACAAAAT-A-A-A--A--AA---G--------------A--A-GG-A-A-A-G-T-GC-T----CA-C----A-T-ACAA--ATT-AAG-AA-G-TTCAG-CTCTG-TCTCAGGAGATG-G--G-G---T----G-T--C-GG--T-G-T-C--C----C-T---G-GTC-G-ACAAG-----A--ACA--G-A-C-G-T--CTC--CTCG-TC---A-TCA-GT-G-GACTC---TTGGCTAA-GTG-G-TG---T-C--G--TC-A-T-C--A-G-C-ATCT-C------CCC---GCT---G-TGGGA-GTC--CA---T--C----CA-TC-------C-T-AA-GT---C-AGCA----GCA--G--A--GCG-T-G-C-CTGG---------G-GC-GTGAGCA--G-T-T-G--G---A-G-G-GAC---C-------G-A--C-C-AG----T-GG-A-G---TG-T-GCGTGTC--GGAAG-G---C--A-G-TCT-ACCC---A-GT-CGTGA--C-T--G-AGCACAAATG-TGCA-A-T-T----G-T---CAT---T-TTC-TTAGCA-TG-TCAAGATTTT-TA---T-TA-ATGCCTTTAGAA-T-TA-AAT-AAAA-G-TC--C-T-TTTTT----------G-A-A-ATCTTG-
```



<br />

#### 1.11. Writing to ALIGN format *.ALIGN <a id="writing-align"></a>

```
st.write_alignments(decoded_alignment_file, path = None, name = 'alignments_file')
```

    This function saves into FASTA-ALIGNMENT *.align
    
    Args:
       decoded_alignment_file (str/FASTA) - sequences provided in FASTA format from decode_alignments()
       path (str | None) - the path to save. If None save it to the current working directory. Default: None
       name (str) - the name of the saving file. Default: 'alignments_file'

       

<br />

#### 1.12. Extracting consensus parts of alignments <a id="extracting-consensuse"></a>

```
consensuse = st.ExtractConsensuse(alignment_file, refseq_sequences = None)
```

    This function extracts consensus fragments of sequences alignments from alignment_file obtained in the MuscleMultipleSequence Alignment() function
    
    Args:
       alignment_file (Bio.Align.MultipleSeqAlignment class) - the output file from MuscleMultipleSequenceAlignment()
       refseq_sequences (dict | None) - dictionary obtained from get_sequences_gene() or get_sequences_accesion(), which add additional information to results. If None results will be reduced to only consensus sequences.
    
    Returns:
        dict: The dictionary containing consensus fragments
       

<br />

#### 1.13. Passing sequence from an external source <a id="passing-sequence"></a>

```
sequence = st.load_sequence()
```

    
    This function makes it easy to load the genetic sequences to variable
    
    
    Returns:
        str: Input sequence in a variable
       

<br />

#### 1.14. Clearing junk characters from the sequence <a id="clearing-sequence"></a>

```
sequence = st.clear_sequence(sequence)
```

        
    This function clear sequence from special characters, spaces, numbers that may be in the sequence when copied from external sources.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code
        upac_code (list) - list of nucleotides in which the sequence is encoded. Default: ['A','C','T','G','N','M','R','W','S','Y','K','V','H','D','B','U', 'Ψ']

    Returns:
        str: The genetic sequence after clearing
       

<br />

#### 1.15. Checking that the sequence is coding protein (CDS) <a id="checking-cds"></a>

```
dec_coding = st.check_coding(sequence)
```

    This function checks that the input sequence belongs to the (CDS) coding sequence. Checkpoints include the start with ATG and include 3-nucleotide repeats.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code

    Returns:
        bool: True/False
       

<br />

#### 1.16. Checking that all bases in sequence are contained in the UPAC code <a id="checking-upac"></a>

```
dec_upac = st.check_upac(sequence)
```

    This function checks that the input sequence elements are included in UPAC code.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code
        upac_code (list) - list of nucleotides in which the sequence is encoded. Default: ['A','C','T','G','N','M','R','W','S','Y','K','V','H','D','B','U', 'Ψ']

    Returns:
        bool: True/False
       

<br />

#### 1.17. Reversing the DNA / RNA sequence: 5' --> 3' and 3' --> 5' <a id="reversing"></a>

```
reversed_sequence = st.reverse(sequence) 
```

    This function reverses the input genetic sequence from 5' -> 3' to 3' -> 5' and opposite.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code

    Returns:
        str: The genetic sequence after reversing
       

<br />

#### 1.18. Complementing the DNA / RNA second strand sequence <a id="complementing"></a>

```
complementary_sequence = st.complement(sequence)
```

    This function makes a complementary sequence to the input genetic sequence on the nucleotide pairs from the extended UPAC code.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code

    Returns:
        str: The complementary sequence
       

<br />

#### 1.19. Changing DNA to RNA sequence <a id="dna-rna"></a>

```
rna_sequence = st.dna_to_rna(sequence, enrichment= False)
```

    This function changes the sequence from DNA format to RNA.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code
        enrichment (bool) - If True, the nucleotides in the RNA sequence instead of uracil (U) will be replaced with pseudouridine (Ψ) (True/False). Default: False

    Returns:
        str: The RNA sequence
       

<br />

#### 1.20. Changing RNA to DNA sequence <a id="rna-dna"></a>

```
dna_sequence = st.rna_to_dna(rna_sequence)
```

    
    This function changes the sequence from RNA format to DNA.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code

    Returns:
        str: The DNA sequence
       

<br />

#### 1.21. Changing DNA or RNA sequence to amino acid / protein sequence <a id="dna-protein"></a>

```
protein_sequence = st.seuqence_to_protein(dna_sequence, metadata)
```

    This function changes the sequence from (CDS) RNA or DNA format to protein sequence.
    
    Args:
        sequence (str) - nucleotide sequence provided in UPAC code
        metadata (dict) - set of metadata loaded vie load_metadata()

    Returns:
        str: The protein sequence
       


<br />

#### 1.22. Prediction of RNA / DNA sequence secondary structure <a id="prediction"></a>

```
figure, dot = predict_structure(sequence, 
                  anty_sequence = '',
                  height=None, 
                  width=None, 
                  dis_alpha = 0.35, 
                  seq_force = 27, 
                  pair_force = 8, 
                  show_plot = True)

figure.savefig('predicted_structure.svg')

```

    
    Predict and visualize the secondary structure of RNA or DNA sequences.

    The function uses the ViennaRNA package to fold a nucleotide sequence (or 
    a sequence with its complementary/antisense strand) and generates a 
    secondary structure in dot-bracket notation. The structure is visualized 
    as a network graph where nodes represent nucleotides and edges represent 
    base pairs and backbone connections.

    Args:
        sequence (str): Nucleotide sequence in IUPAC notation (ATGC/U).
        anty_sequence (str, optional): Antisense/complementary sequence. 
            If provided, duplex folding is performed instead of single-strand folding. 
            Default is '' (single-strand folding).
        height (int | float | None, optional): Height of the figure in inches. 
            If None, it is determined automatically based on sequence length.
        width (int | float | None, optional): Width of the figure in inches. 
            If None, it is determined automatically based on sequence length.
        dis_alpha (float, optional): Adjustment factor (0–1) controlling the 
            attraction of paired nucleotides in the visualization. Default is 0.35. 
            - Recommended for short sequences (~25 nt): 0.35 (default).
            - Recommended for longer sequences (e.g. mRNA): ~0.1.
        
        seq_force (int, optional): Edge weight for base-pair connections 
            in the layout algorithm. Default is 27.
        pair_force (int, optional): Edge weight for backbone connections 
            in the layout algorithm. Default is 8.
            - Recommended for short sequences (~25 nt): 8 (default).
            - Recommended for longer sequences (e.g. mRNA): ~3.
       
        show_plot (bool, optional): If True, the plot is displayed. 
            If False, the figure is returned without showing. Default is True.

    Returns:
        tuple:
            - fig (matplotlib.figure.Figure): Generated Matplotlib figure object.
            - dot_bracket_structure (str): Predicted secondary structure in 
              dot-bracket notation (e.g. "..((..))..").


<br />    

##### Example of structure prediction graph:

* shRNA

<p align="center">
<img  src="https://raw.githubusercontent.com/jkubis96/JBioSeqTools/0b59ecba7ae57b9e0636c83ee71a98465f08424f/fig/sh.svg" alt="drawing" width="600" />
</p>

* siRNA

<p align="center">
<img  src="https://raw.githubusercontent.com/jkubis96/JBioSeqTools/ad97ffd417f71f3b0de55b5343f2870a276d63d5/fig/sirna.svg" alt="drawing" width="600" />
</p>

* mRNA

<p align="center">
<img  src="https://raw.githubusercontent.com/jkubis96/JBioSeqTools/0b59ecba7ae57b9e0636c83ee71a98465f08424f/fig/mrna.svg" alt="drawing" width="600" />
</p>


<br />

#### 1.23. Prediction of RNAi on the provided sequence <a id="rnai-prediction"></a>

```
RNAi_data =  st.FindRNAi(sequence, metadata, length = 23, n = 200, max_repeat_len = 3, max_off = 1, species = 'human', output = None, database_name = "refseq_select_rna",  evalue = 1e-3, outfmt =  5, word_size = 7, max_hsps = 20, reward = 1, penalty = -3, gapopen = 5, gapextend = 2, dust = "no", extension = 'xml')    
```


<br />

##### Example of data frame output:

|RNAi_name|RNAi_seq               |target                                      |e-value       |bit_score  |alignment_length|target_seq                 |target_gene_name|species         |specificity|complemenatry_regions|complemenatry_pct  |RNAi_sense             |repeated_motif|repeated_motif_pct|score|GC%  |
|---------|-----------------------|--------------------------------------------|--------------|-----------|----------------|---------------------------|--------------- |----------------|-----------|---------------------|-------------------|-----------------------|--------------|------------------|-----|-----|
|RNAi_66  |TGATTTTGTCTGAAACCCATATA|['Homo sapiens survival of motor neuron 1']|[2.07974e-05] |  [46.087] |     [23]       |['TGATTTTGTCTGAAACCCATATA']|    ['SMN1']    |['Homo sapiens']|     1     |['ATAT', 'TATA']     |0.34782608695652173|TATATGGGTTTCAGACAAAATCA|['TTTT']      |        0.17      |0.0  |17.04|
|RNAi_11  |TTGATTTTGTCTGAAACCCATAT|['Homo sapiens survival of motor neuron 1']|[2.07974e-05] |  [46.087] |     [23]       |['TTGATTTTGTCTGAAACCCATAT']|    ['SMN1']    |['Homo sapiens']|     1     |['ATAT']             |0.17391304347826086|ATATGGGTTTCAGACAAAATCAA|['TTTTTT']    |        0.26      |-3.0 |17.04|

<br />

Columns explanation:
* RNAi_name - name added by algorithms in the course of searching and predicting RNAi's
* RNAi_seq - the sequence of RNAi (reverse-complementary to a sequence that should be silenced)
* target - name of the targeted sequence
* e-value (expect value) - the probability of finding the observed alignment or a better one by random chance
* bit_score - statistical measure that provides an indication of the significance of a sequence alignment
* alignment_length - size of the alignment complementarity to the blasted sequence
* target_seq - part of the blasted sequence complementary to the RNAi_seq (in the same rotation as RNAi)
* target_gene_name - list of genes to which the RNAi is complementary
* species - list of species to which the gene sequence is complementary
* specificity - number of genes to which the RNAi is complementary
* complemenatry_regions - complementary part of RNAi inside the RNAi sequence
* complemenatry_pct - percent of complementary nucleotides inside RNAi
* RNAi_sense - sense strand of RNAi (reverse-complement to the RNAi_seq)
* repeated_motif - sequences with repeated sequences of the same nucleotide inside RNAi
* repeated_motif_pct - percent of nucleotides from sequences with repeated sequences of the same nucleotide inside RNAi
* score - algorithmically given points to particular RNAi sequences based on knowledge from previous works and papers: \
	-DOI:10.1093/nar/gkn902 \
	-DOI:10.1093/nar/gkh247 \
	-DOI:10.1038/nbt936 \
	-DOI:10.1016/j.bbrc.2004.02.157
	
* GC% - percent content of G and C nucleotides in RNAi sequence (best target between 35-55%)

<br />


#### 1.24. Correcting of RNAi_data for complementarity to the loop sequence <a id="correcting-loop"></a>

```
RNAi_data = st.loop_complementary_adjustment(RNAi_data, loop_seq, min_length=3)
```

    This function takes output DataFrame from Find RNAi() or remove_specific_to_sequence() reducing the RNAi score on their complementarity to the provided loop sequence.
    It allows the choice of RNAi with better biological functionality.
    
    Args:
       RNAi_data (DataFrame) - data frame obtained in the FindRNAi() or remove_specific_to_sequence() function
       loop_seq (str) - sequence of the loop in the UPAC code for siRNA / shRNA creation
       min_length (int) - min value of loop complementary nucleotides. Default: 3
      

    Returns:
        DataFrame: Data frame containing predicted RNA sequence (sense / antisense), target, scores, and statistics corrected by reducing complementary to loop sequence.
       


<br />


##### Example of data frame output:

|RNAi_name|RNAi_seq               |target                                      |e-value       |bit_score  |alignment_length|target_seq                 |target_gene_name|species         |specificity|complemenatry_regions|complemenatry_pct  |RNAi_sense             |repeated_motif|repeated_motif_pct|score|GC%  |sense_loop_complementary|sense_loop_complementary_pct|antisense_loop_complementary|antisense_loop_complementary_pct|
|---------|-----------------------|--------------------------------------------|--------------|-----------|----------------|---------------------------|--------------- |----------------|-----------|---------------------|-------------------|-----------------------|--------------|------------------|-----|-----|------------------------|----------------------------|----------------------------|--------------------------------|
|RNAi_66  |TGATTTTGTCTGAAACCCATATA|['Homo sapiens survival of motor neuron 1'] |[2.07974e-05] |  [46.087] |     [23]       |['TGATTTTGTCTGAAACCCATATA']|    ['SMN1']    |['Homo sapiens']|     1     |['ATAT', 'TATA']     |0.34782608695652173|TATATGGGTTTCAGACAAAATCA|['TTTT']      |        0.17      |0.0  |17.04|[]                      |0.0                         |[]                          |0.0                             |
|RNAi_11  |TTGATTTTGTCTGAAACCCATAT|['Homo sapiens survival of motor neuron 1'] |[2.07974e-05] |  [46.087] |     [23]       |['TTGATTTTGTCTGAAACCCATAT']|    ['SMN1']    |['Homo sapiens']|     1     |['ATAT']             |0.17391304347826086|ATATGGGTTTCAGACAAAATCAA|['TTTTTT']    |        0.26      |-3.0 |17.04|[]                      |0.0                         |[]                          |0.0                             |

<br />

Columns explanation:
* RNAi_name - name added by algorithms in the course of searching and predicting RNAi's
* RNAi_seq - the sequence of RNAi (reverse-complementary to a sequence that should be silenced)
* target - name of the targeted sequence
* e-value (expect value) - the probability of finding the observed alignment or a better one by random chance
* bit_score - statistical measure that provides an indication of the significance of a sequence alignment
* alignment_length - size of the alignment complementarity to the blasted sequence
* target_seq - part of the blasted sequence complementary to the RNAi_seq (in the same rotation as RNAi)
* target_gene_name - list of genes to which the RNAi is complementary
* species - list of species to which the gene sequence is complementary
* specificity - number of genes to which the RNAi is complementary
* complemenatry_regions - complementary part of RNAi inside the RNAi sequence
* complemenatry_pct - percent of complementary nucleotides inside RNAi
* RNAi_sense - sense strand of RNAi (reverse-complement to the RNAi_seq)
* repeated_motif - sequences with repeated sequences of the same nucleotide inside RNAi
* repeated_motif_pct - percent of nucleotides from sequences with repeated sequences of the same nucleotide inside RNAi
* score - algorithmically given points to particular RNAi sequences based on knowledge from previous works and papers: \
	-DOI:10.1093/nar/gkn902 \
	-DOI:10.1093/nar/gkh247 \
	-DOI:10.1038/nbt936 \
	-DOI:10.1016/j.bbrc.2004.02.157 
	
* GC% - percent content of G and C nucleotides in RNAi sequence (best target between 35-55%)
* sense_loop_complementary - part of sense strand RNAi complementary to the loop
* sense_loop_complementary_pct - percent of nucleotides from the sense strand of RNAi complementary to the loop
* antisense_loop_complementary - part of antisense strand RNAi complementary to the loop
* antisense_loop_complementary_pct - percent of nucleotides from the antisense strand of RNAi complementary to the loop



<br />

#### 1.25. Correcting of RNAi_data for complementarity to the additional external sequence <a id="correcting-sequence"></a>

```
RNAi_data = st.remove_specific_to_sequence(RNAi_data, sequence, min_length=4)
```

    Th