Skip to content

Commit

Permalink
Added more graphing functionality and basic testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanIsALion committed Jan 15, 2021
1 parent 93cfcb3 commit 3b5bbb6
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 16 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ By default, the output graphs have a DPI of 150. However, the user can change th

$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -D 300

**Specify the lines across a graph:**
``-lines`` / ``--line_intervals``

By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using the ``-lines`` / ``--line_intervals`` argument

$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -lines 0.1 0.2 0.3 0.4 0.5


**Remove non-alphabetic characters from file names -**
By default, the output files contain characters that are non-alphabetic (for example, *predicted_disorder_sp|Q8N6T3|.png*). This is not a problem on some operating systems, but others do not allow files to have names that contain certain characters. To get around this, you can add the ``--remove_characters`` flag. This will remove all non-alphabetic characters from the .fasta header when saving the file. The previous example with the header >sp|Q8N6T3|ARFG1_HUMAN would now save as *predicted_disorder_spQ8N726AR.png*.

Expand Down Expand Up @@ -137,6 +145,14 @@ By default, the output graph has a DPI of 150. However, the user can change the
meta.graph_disorder("DAPPTSQEHTQAEDKERD", DPI=300)


**Specify the lines across a graph -**
By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using specifying *line_intervals*

**Example**

meta.graph_disorder("DAPPTSQEHTQAEDKERD", line_intervals = [0.1, 0.2, 0.3]


### Calculating Percent Disorder
The ``percent_disorder`` function will return the percent of residues in a sequence that have predicted consensus disorder values of 50% or more (as a decimal value).

Expand Down Expand Up @@ -263,6 +279,11 @@ https://github.com/idptools/metapredict/issues
### Recent changes
This section is a log of recent changes with metapredict. My hope is that as I change things, this section can help you figure out why a change was made and if it will break any of your current work flows. The first major changes were made for the 0.56 release, so tracking will start there. Reasons are not provided for bug fixes for because the reason can assumed to be fixing the bug...

#### V0.60
Change:
Added functionality to specify the horizontal lines that appear across the graphs rather than only having the option of having the dashed lines appear at intervals of 0.2.
This functionality is in both Python and the command line.

#### V0.58
Change:
Updated the network with a newly trained network (using the same dataset as the original) that is slightly more accurate.
Expand Down
Binary file modified docs/_build/doctrees/changes.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/usage/command-line.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/usage/using-in-python.doctree
Binary file not shown.
7 changes: 7 additions & 0 deletions docs/_build/html/_sources/changes.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ About
------
This section is a log of recent changes with metapredict. My hope is that as I change things, this section can help you figure out why a change was made and if it will break any of your current work flows. The first major changes were made for the 0.56 release, so tracking will start there.

V.060
------

Change:
Added functionality to specify the horizontal lines that appear across the graphs rather than only having the option of having the dashed lines appear at intervals of 0.2.
This functionality is in both Python and the command line.

V0.58
------

Expand Down
11 changes: 11 additions & 0 deletions docs/_build/html/_sources/usage/command-line.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ By default, the output files have a DPI of 150. However, the user can change the
$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -D 300
**Specify the lines across a graph:**
``-lines`` / ``--line_intervals``

By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using the ``-lines`` / ``--line_intervals`` argument

.. code-block:: bash
$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -lines 0.1 0.2 0.3 0.4 0.5
**Remove non-alphabetic characters from file name:**
``--remove_characters``

Expand Down
12 changes: 12 additions & 0 deletions docs/_build/html/_sources/usage/using-in-python.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ By default, the output graph has a DPI of 150. However, the user can change the
meta.graph_disorder("DAPPTSQEHTQAEDKERD", DPI=300)
**Specify the lines across a graph:**
``-lines`` / ``--line_intervals``

By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using specifying *line_intervals*

**Example**

.. code-block:: python
meta.graph_disorder("DAPPTSQEHTQAEDKERD", line_intervals = [0.1, 0.2, 0.3])
Calculating Percent Disorder:
-----------------------------

Expand Down
9 changes: 9 additions & 0 deletions docs/_build/html/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<li class="toctree-l1"><a class="reference internal" href="usage/troubleshooting.html">Metapredict isn’t working!</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Recent changes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#about">About</a></li>
<li class="toctree-l2"><a class="reference internal" href="#v-060">V.060</a></li>
<li class="toctree-l2"><a class="reference internal" href="#v0-58">V0.58</a></li>
<li class="toctree-l2"><a class="reference internal" href="#v0-57">V0.57</a></li>
<li class="toctree-l2"><a class="reference internal" href="#v0-56">V0.56</a></li>
Expand Down Expand Up @@ -164,6 +165,14 @@ <h1>Recent changes<a class="headerlink" href="#recent-changes" title="Permalink
<h2>About<a class="headerlink" href="#about" title="Permalink to this headline"></a></h2>
<p>This section is a log of recent changes with metapredict. My hope is that as I change things, this section can help you figure out why a change was made and if it will break any of your current work flows. The first major changes were made for the 0.56 release, so tracking will start there.</p>
</div>
<div class="section" id="v-060">
<h2>V.060<a class="headerlink" href="#v-060" title="Permalink to this headline"></a></h2>
<p>Change:
Added functionality to specify the horizontal lines that appear across the graphs rather than only having the option of having the dashed lines appear at intervals of 0.2.</p>
<blockquote>
<div><p>This functionality is in both Python and the command line.</p>
</div></blockquote>
</div>
<div class="section" id="v0-58">
<h2>V0.58<a class="headerlink" href="#v0-58" title="Permalink to this headline"></a></h2>
<p>Change:
Expand Down
1 change: 1 addition & 0 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ <h1>Welcome to metapredict’s documentation!<a class="headerlink" href="#welcom
</li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Recent changes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changes.html#about">About</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#v-060">V.060</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#v0-58">V0.58</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#v0-57">V0.57</a></li>
<li class="toctree-l2"><a class="reference internal" href="changes.html#v0-56">V0.56</a></li>
Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/_build/html/usage/command-line.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<li class="toctree-l1"><a class="reference internal" href="../api.html">Module Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="acknowledgements.html">Acknowledgements</a></li>
<li class="toctree-l1"><a class="reference internal" href="troubleshooting.html">Metapredict isn’t working!</a></li>
<li class="toctree-l1"><a class="reference internal" href="../changes.html">Recent changes</a></li>
</ul>


Expand Down Expand Up @@ -202,6 +203,12 @@ <h2>Graphing Disorder<a class="headerlink" href="#graphing-disorder" title="Perm
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -D <span class="m">300</span>
</pre></div>
</div>
<p><strong>Specify the lines across a graph:</strong>
<code class="docutils literal notranslate"><span class="pre">-lines</span></code> / <code class="docutils literal notranslate"><span class="pre">--line_intervals</span></code></p>
<p>By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using the <code class="docutils literal notranslate"><span class="pre">-lines</span></code> / <code class="docutils literal notranslate"><span class="pre">--line_intervals</span></code> argument</p>
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -lines <span class="m">0</span>.1 <span class="m">0</span>.2 <span class="m">0</span>.3 <span class="m">0</span>.4 <span class="m">0</span>.5
</pre></div>
</div>
<p><strong>Remove non-alphabetic characters from file name:</strong>
<code class="docutils literal notranslate"><span class="pre">--remove_characters</span></code></p>
<p>By default, the output files contain characters that are non-alphabetic (for example, <em>predicted_disorder_sp|Q8N6T3|.png</em>). This is not a problem on some operating systems, but others do not allow files to have names that contain certain characters. To get around this, you can add the <code class="docutils literal notranslate"><span class="pre">--remove_characters</span></code> flag. This will remove all non-alphabetic characters from the .fasta header when saving the file. The previous example with the header &gt;sp|Q8N6T3|ARFG1_HUMAN would now save as <em>predicted_disorder_spQ8N726AR.png</em>.</p>
Expand Down
9 changes: 9 additions & 0 deletions docs/_build/html/usage/using-in-python.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="../api.html">Module Documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="acknowledgements.html">Acknowledgements</a></li>
<li class="toctree-l1"><a class="reference internal" href="troubleshooting.html">Metapredict isn’t working!</a></li>
<li class="toctree-l1"><a class="reference internal" href="../changes.html">Recent changes</a></li>
</ul>


Expand Down Expand Up @@ -206,6 +208,13 @@ <h2>Graphing Disorder<a class="headerlink" href="#graphing-disorder" title="Perm
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">meta</span><span class="o">.</span><span class="n">graph_disorder</span><span class="p">(</span><span class="s2">&quot;DAPPTSQEHTQAEDKERD&quot;</span><span class="p">,</span> <span class="n">DPI</span><span class="o">=</span><span class="mi">300</span><span class="p">)</span>
</pre></div>
</div>
<p><strong>Specify the lines across a graph:</strong>
<code class="docutils literal notranslate"><span class="pre">-lines</span></code> / <code class="docutils literal notranslate"><span class="pre">--line_intervals</span></code></p>
<p>By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using specifying <em>line_intervals</em></p>
<p><strong>Example</strong></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">meta</span><span class="o">.</span><span class="n">graph_disorder</span><span class="p">(</span><span class="s2">&quot;DAPPTSQEHTQAEDKERD&quot;</span><span class="p">,</span> <span class="n">line_intervals</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">])</span>
</pre></div>
</div>
</div>
<div class="section" id="calculating-percent-disorder">
<h2>Calculating Percent Disorder:<a class="headerlink" href="#calculating-percent-disorder" title="Permalink to this headline"></a></h2>
Expand Down
7 changes: 7 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ About
------
This section is a log of recent changes with metapredict. My hope is that as I change things, this section can help you figure out why a change was made and if it will break any of your current work flows. The first major changes were made for the 0.56 release, so tracking will start there.

V.060
------

Change:
Added functionality to specify the horizontal lines that appear across the graphs rather than only having the option of having the dashed lines appear at intervals of 0.2.
This functionality is in both Python and the command line.

V0.58
------

Expand Down
11 changes: 11 additions & 0 deletions docs/usage/command-line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ By default, the output files have a DPI of 150. However, the user can change the
$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -D 300
**Specify the lines across a graph:**
``-lines`` / ``--line_intervals``

By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using the ``-lines`` / ``--line_intervals`` argument

.. code-block:: bash
$ metapredict-graph-disorder /Users/thisUser/Desktop/interestingProteins.fasta /Users/thisUser/Desktop/DisorderGraphsFolder/ -lines 0.1 0.2 0.3 0.4 0.5
**Remove non-alphabetic characters from file name:**
``--remove_characters``

Expand Down
12 changes: 12 additions & 0 deletions docs/usage/using-in-python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ By default, the output graph has a DPI of 150. However, the user can change the
meta.graph_disorder("DAPPTSQEHTQAEDKERD", DPI=300)
**Specify the lines across a graph:**
``-lines`` / ``--line_intervals``

By default, the graphs have horizontal dashed lines at intervals of 0.2 from 0 to 1. Now, can specify the location of the dashed lines by using specifying *line_intervals*

**Example**

.. code-block:: python
meta.graph_disorder("DAPPTSQEHTQAEDKERD", line_intervals = [0.1, 0.2, 0.3])
Calculating Percent Disorder:
-----------------------------

Expand Down
7 changes: 4 additions & 3 deletions metapredict/backend/meta_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from metapredict.backend import meta_predict_disorder
from metapredict.backend.meta_predict_disorder import meta_predict as predict

def graph(sequence, name = " ", line_color = "blue", DPI = 150, save_fig = False, output_file = "./predicted_disorder.png"):
def graph(sequence, name = " ", line_color = "blue", cutoffLines=[], DPI = 150, save_fig = False, output_file = "./predicted_disorder.png"):
"""
Function for graphing predicted disorder. By default, this function will show a graph.
However, if saveFig = True, then it will save the figure (by default) to the location
Expand Down Expand Up @@ -70,8 +70,9 @@ def graph(sequence, name = " ", line_color = "blue", DPI = 150, save_fig = False
for i in range(0, len(yValues)):
disorderValues.append(0.5)
axes.plot(xValues, disorderValues, color = "black", linewidth = "1.25")
#add dashed lines at 0.2 intervals
cutoffLines = [0.2, 0.4, 0.6, 0.8]
#add dashed lines at 0.2 intervals if cutoff lines not specified
if cutoffLines == []:
cutoffLines = [0.2, 0.4, 0.6, 0.8]
for i in cutoffLines:
tempList = []
for j in range(0, len(yValues)):
Expand Down
1 change: 1 addition & 0 deletions metapredict/backend/meta_predict_disorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def meta_predict(sequence, normalized=True, network=brnn_network, device=device,
#get output values from the seq_vector based on the network (brnn_network)
outputs = network(seq_vector.float()).detach().numpy()[0]


#make empty list to add in outputs
output_values = []
#for the values 'i' in outputs
Expand Down
34 changes: 23 additions & 11 deletions metapredict/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def predict_disorder(sequence, normalized=True):
return meta_predict(sequence, normalized=normalized)


def graph_disorder(sequence, name = " ", DPI=150):
def graph_disorder(sequence, line_intervals=[], name = " ", DPI=150):
"""
Function to plot the disorder of an input sequece. Displays immediately.
Expand All @@ -54,14 +54,19 @@ def graph_disorder(sequence, name = " ", DPI=150):
for example set name = "- PAB1", the title on the graph will be "Predicted
Protein Disorder - PAB1".
line_intervals (optional) : List
A list of values that you would like to have for lines across the X-axis.
The default puts lines at intervals of 0.2.
Example: line_intervals = [0.1, 0.2, 0.3, 0.4, 0.5]
DPI (optional) - default value is 150. Increasing this value will increase
the resolution of the output graph. Decreasing this value will decrease
the resolution.
"""
#make all residues upper case
sequence=sequence.upper()
#graph sequence
graph(sequence = sequence, name = name, DPI=DPI)
graph(sequence = sequence, name = name, cutoffLines=line_intervals, DPI=DPI)



Expand Down Expand Up @@ -246,21 +251,28 @@ def predict_disorder_fasta(filepath, save=False, output_path = "", output_name =
#print IO error
print("IO error")

def graph_disorder_fasta(filepath, DPI=150, save=True, output_path="", remove_characters=False):
def graph_disorder_fasta(filepath, DPI=150, line_intervals=[], save=True, output_path="", remove_characters=False):
"""
Function to make graphs of predicted disorder from the sequences
in a specified .fasta file. By default will save the generated
graphs to the location output_path specified in filepath.
Arguments:
----------
filepath - the path to where the .fasta file is located. The filepath
should end in the file name. For example (on MacOS):
filepath="/Users/thisUser/Desktop/folder_of_seqs/interesting_proteins.fasta"
filepath : String
the path to where the .fasta file is located. The filepath
should end in the file name. For example (on MacOS):
filepath="/Users/thisUser/Desktop/folder_of_seqs/interesting_proteins.fasta"
DPI (optional) - default value is 150. Increasing this value will increase
the resolution of the output graph. Decreasing this value will decrease
the resolution.
DPI (optional) : Int
default value is 150. Increasing this value will increase
the resolution of the output graph. Decreasing this value will decrease
the resolution.
line_intervals (optional) : List
A list of values that you would like to have for lines across the X-axis.
The default puts lines at intervals of 0.2.
Example: line_intervals = [0.1, 0.2, 0.3, 0.4, 0.5]
save (optional) - by default, the generated graphs are saved. This can be set
to False, which will result in the graphs being sequentially shown.
Expand Down Expand Up @@ -375,8 +387,8 @@ def graph_disorder_fasta(filepath, DPI=150, save=True, output_path="", remove_ch
#of the fasta header either as is or with characters removed if remove_characters is set to true).
output = "{}predicted_disorder_{}.png".format(output_path, name)
#use the graph function (specified in meta_graph from the backend) to save the graph.
graph(sequence = sequence, name = title, DPI = DPI, save_fig = True, output_file = output)
graph(sequence = sequence, name = title, cutoffLines=line_intervals, DPI = DPI, save_fig = True, output_file = output)
else:
#if save was set to False, then just graph the sequences from the .fasta file and show them immediately.
graph(sequence = sequence, name = title, DPI = DPI)
graph(sequence = sequence, name = title, cutoffLines=line_intervals, DPI = DPI)

Loading

0 comments on commit 3b5bbb6

Please sign in to comment.