msaexplorer 0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,133 @@
1
+ r"""
2
+ # What is MSAexplorer?
3
+
4
+ MSAexplorer allows the analysis and straight forward plotting of multiple sequence alignments.
5
+ Its focus is to act as a simple python3 extension or shiny app with minimal dependencies and syntax. It's easy
6
+ to set up and highly customizable.
7
+
8
+ # Usage as a shiny application
9
+
10
+ The current version of the app is deployed to [GitHub pages](https://jonas-fuchs.github.io/MSAexplorer/app/). This application is serverless, and all
11
+ computation runs through your browser. There is no need to install anything. Enjoy the app!
12
+
13
+ However, you can also deploy it yourself and host it however you like!
14
+
15
+ ```bash
16
+ git clone https://github.com/jonas-fuchs/MSAexplorer
17
+ cd MSAexplorer
18
+ pip install -r requirements.txt # installs all dependencies
19
+ shiny run app.py
20
+ ```
21
+
22
+ Now just follow the link provided in your terminal.
23
+
24
+
25
+ # Usage as a python3 package
26
+
27
+ ## Installation
28
+
29
+ Some simple steps are needed at the moment but in the future you will be able to install MSAexplorer via `pip install msaexplorer`.
30
+
31
+ ```bash
32
+ git clone https://github.com/jonas-fuchs/MSAexplorer
33
+ cd MSAexplorer
34
+ pip install .
35
+ ```
36
+
37
+ Now you are able to use MSAexplorer like any package that you would install via `pip`.
38
+
39
+ ## Analysis
40
+
41
+ The `explore` module lets you load an alignment file and analyze it.
42
+
43
+ ```python
44
+ '''
45
+ a small example on how to use the MSAexplorer package
46
+ '''
47
+
48
+ from msaexplorer import explore
49
+
50
+ # load MSA
51
+ msa = explore.MSA('example_alignments/DNA.fasta')
52
+ annotation = explore.Annotation(msa, 'example_alignments/DNA_RNA.gff3')
53
+
54
+ # you can set the zoom range and the reference id if needed
55
+ msa.zoom = (0, 1500)
56
+ msa.reference_id = 'your_ref_id'
57
+
58
+ # access functions on what to compute on the MSA
59
+ msa.calc_pairwise_identity_matrix()
60
+ ```
61
+
62
+ Importantly, multiple sequence alignments should have the format:
63
+
64
+ ```
65
+ >Seq1
66
+ ATCGATCGATCGATCG
67
+ >Seq2
68
+ ATCGATCGATCGATCG
69
+ >Seq3
70
+ ATCGATCGATCGATCG
71
+ ```
72
+
73
+ Additionally, you can also read in an annotation in `bed`, `gff3` or `gb` format and connect them to the MSA. Importantly,
74
+ the sequence identifier has to be part of the alignment. All genomic locations are then automatically adapted to the
75
+ alignment.
76
+
77
+ ## Plotting
78
+
79
+ The plotting `draw` module has several predefined functions to draw alignments.
80
+
81
+ ```python
82
+ '''
83
+ an example demonstrating how to plot multiple sequence alignments
84
+ '''
85
+ # import all packages
86
+ import matplotlib.pyplot as plt
87
+ from msaexplorer import explore
88
+ from msaexplorer import draw
89
+
90
+ # load alignment
91
+ aln = explore.MSA("example_alignments/DNA.fasta", reference_id=None, zoom_range=None)
92
+ # set reference to e.g. the first sequence
93
+ aln.reference_id = list(aln.alignment.keys())[0]
94
+
95
+ fig, ax = plt.subplots(nrows=2, height_ratios=[0.2, 2], sharex=False)
96
+
97
+ draw.stat_plot(
98
+ aln,
99
+ ax[0],
100
+ stat_type="entropy",
101
+ rolling_average=1,
102
+ line_color="indigo"
103
+ )
104
+
105
+ draw.identity_alignment(
106
+ aln,
107
+ ax[1],
108
+ show_gaps=False,
109
+ show_mask=True,
110
+ show_mismatches=True,
111
+ reference_color='lightsteelblue',
112
+ color_scheme='purine_pyrimidine',
113
+ show_seq_names=False,
114
+ show_ambiguities=True,
115
+ fancy_gaps=True,
116
+ show_x_label=False,
117
+ show_legend=True,
118
+ bbox_to_anchor=(1,1.05)
119
+ )
120
+
121
+ plt.show()
122
+ ```
123
+ """
124
+
125
+ import importlib.metadata, pathlib, tomllib
126
+
127
+ # get __version__ from pyproject.toml
128
+ source_location = pathlib.Path("__file__").parent
129
+ if (source_location.parent / "pyproject.toml").exists():
130
+ with open(source_location.parent / "pyproject.toml", "rb") as f:
131
+ __version__ = tomllib.load(f)['project']['version']
132
+ else:
133
+ __version__ = importlib.metadata.version("msaexplorer")