diff --git a/.DS_Store b/.DS_Store index c4d4053..47b466d 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index c5c192a..7428e9a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ __pycache__/ # Distribution / packaging .Python env/ +build/ develop-eggs/ dist/ downloads/ diff --git a/README.md b/README.md index c3aaa47..8e57e63 100644 --- a/README.md +++ b/README.md @@ -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*. @@ -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). @@ -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. diff --git a/docs/_build/doctrees/changes.doctree b/docs/_build/doctrees/changes.doctree index d18f00f..2c1487c 100644 Binary files a/docs/_build/doctrees/changes.doctree and b/docs/_build/doctrees/changes.doctree differ diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index da2bc89..0904725 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/usage/command-line.doctree b/docs/_build/doctrees/usage/command-line.doctree index b56b35a..aa36b00 100644 Binary files a/docs/_build/doctrees/usage/command-line.doctree and b/docs/_build/doctrees/usage/command-line.doctree differ diff --git a/docs/_build/doctrees/usage/using-in-python.doctree b/docs/_build/doctrees/usage/using-in-python.doctree index 5169fd4..078aa6a 100644 Binary files a/docs/_build/doctrees/usage/using-in-python.doctree and b/docs/_build/doctrees/usage/using-in-python.doctree differ diff --git a/docs/_build/html/_sources/changes.rst.txt b/docs/_build/html/_sources/changes.rst.txt index 853266f..083af1c 100644 --- a/docs/_build/html/_sources/changes.rst.txt +++ b/docs/_build/html/_sources/changes.rst.txt @@ -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 ------ diff --git a/docs/_build/html/_sources/usage/command-line.rst.txt b/docs/_build/html/_sources/usage/command-line.rst.txt index 6bcaf5a..e1e5169 100644 --- a/docs/_build/html/_sources/usage/command-line.rst.txt +++ b/docs/_build/html/_sources/usage/command-line.rst.txt @@ -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`` diff --git a/docs/_build/html/_sources/usage/using-in-python.rst.txt b/docs/_build/html/_sources/usage/using-in-python.rst.txt index 6a88246..8652de7 100644 --- a/docs/_build/html/_sources/usage/using-in-python.rst.txt +++ b/docs/_build/html/_sources/usage/using-in-python.rst.txt @@ -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: ----------------------------- diff --git a/docs/_build/html/changes.html b/docs/_build/html/changes.html index ddf379b..8e40ba0 100644 --- a/docs/_build/html/changes.html +++ b/docs/_build/html/changes.html @@ -89,6 +89,7 @@
  • Metapredict isn’t working!
  • Recent changes @@ -206,6 +208,13 @@

    Graphing Disorder
    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

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

    Calculating Percent Disorder:

    diff --git a/docs/changes.rst b/docs/changes.rst index 853266f..083af1c 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -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 ------ diff --git a/docs/usage/command-line.rst b/docs/usage/command-line.rst index 6bcaf5a..e1e5169 100644 --- a/docs/usage/command-line.rst +++ b/docs/usage/command-line.rst @@ -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`` diff --git a/docs/usage/using-in-python.rst b/docs/usage/using-in-python.rst index 6a88246..8652de7 100644 --- a/docs/usage/using-in-python.rst +++ b/docs/usage/using-in-python.rst @@ -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: ----------------------------- diff --git a/metapredict/backend/meta_graph.py b/metapredict/backend/meta_graph.py index 0225b55..2a6d89b 100644 --- a/metapredict/backend/meta_graph.py +++ b/metapredict/backend/meta_graph.py @@ -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 @@ -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)): diff --git a/metapredict/backend/meta_predict_disorder.py b/metapredict/backend/meta_predict_disorder.py index 06f7238..7896c89 100644 --- a/metapredict/backend/meta_predict_disorder.py +++ b/metapredict/backend/meta_predict_disorder.py @@ -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 diff --git a/metapredict/meta.py b/metapredict/meta.py index 9e4cfa2..96100bf 100644 --- a/metapredict/meta.py +++ b/metapredict/meta.py @@ -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. @@ -54,6 +54,11 @@ 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. @@ -61,7 +66,7 @@ def graph_disorder(sequence, name = " ", DPI=150): #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) @@ -246,7 +251,7 @@ 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 @@ -254,13 +259,20 @@ def graph_disorder_fasta(filepath, DPI=150, save=True, output_path="", remove_ch 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. @@ -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) diff --git a/metapredict/tests/test_metapredict.py b/metapredict/tests/test_metapredict.py index 8b1bdb6..1015644 100644 --- a/metapredict/tests/test_metapredict.py +++ b/metapredict/tests/test_metapredict.py @@ -6,9 +6,16 @@ # Import package, test suite, and other packages as needed import metapredict +from metapredict import meta import pytest import sys def test_metapredict_imported(): """Sample test, will always pass so long as import statement worked""" assert "metapredict" in sys.modules + +def test_metapredict_predictor(): + #testing with normalization + assert meta.predict_disorder('AERDEDNRSKEKKRNKKTNGAGDEHRDKPWSNNSTHPTHRKNEGPMHGDP') == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.998, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.938] + # testing without normalization + assert meta.predict_disorder('AERDEDNRSKEKKRNKKTNGAGDEHRDKPWSNNSTHPTHRKNEGPMHGDP', normalized=False) == [1.055, 1.097, 1.062, 1.087, 1.068, 1.078, 1.089, 1.04, 1.032, 1.025, 1.006, 1.002, 1.007, 0.998, 1.033, 1.032, 1.039, 1.045, 1.061, 1.088, 1.093, 1.092, 1.096, 1.077, 1.058, 1.033, 1.034, 1.019, 1.057, 1.1, 1.05, 1.074, 1.083, 1.078, 1.103, 1.084, 1.052, 1.047, 1.044, 1.065, 1.082, 1.071, 1.119, 1.126, 1.043, 1.13, 1.208, 1.152, 1.155, 0.938] \ No newline at end of file diff --git a/scripts/metapredict-graph-disorder b/scripts/metapredict-graph-disorder index a6127dd..2ee7ba7 100644 --- a/scripts/metapredict-graph-disorder +++ b/scripts/metapredict-graph-disorder @@ -21,11 +21,14 @@ parser.add_argument('data_file', help='Path to fasta file containing sequences t parser.add_argument('output_path', default = 'curdir', help='Path for the returned disorder graphs.') parser.add_argument('-D', '--dpi', default=150, type=int, metavar='DPI', help='Optional. Set DPI to change resolution of output graphs. Default is 150.') +parser.add_argument('-lines', '--line_intervals', default=[], nargs='+', type=float, metavar='line_intervals', + help = 'Optional. Will set the lines going across the x-axis on the graph.') parser.add_argument('--remove_characters', action='store_true', help='Use if you want to avoid using any non-alphabetic characters in the fasta headers as file names') args = parser.parse_args() + DPI=args.dpi if args.output_path == 'curdir': @@ -52,4 +55,4 @@ else: remove_char = False #run graph_disorder_fasta. For more info, see the graph_disorder_fasta function in meta.py. -meta.graph_disorder_fasta(filepath = args.data_file, DPI=DPI, output_path = args.output_path, remove_characters=remove_char) +meta.graph_disorder_fasta(filepath = args.data_file, line_intervals=args.line_intervals, DPI=DPI, output_path = args.output_path, remove_characters=remove_char)