julie-forman-kay-lab / IDPConformerGenerator

Build conformational representations of Intrinsically Disordered Proteins and Regions by a guided sampling of the protein torsion space
https://idpconformergenerator.readthedocs.io/
Apache License 2.0
19 stars 6 forks source link

(FEATURE) Plotting Functions #198

Closed menoliu closed 2 years ago

menoliu commented 2 years ago

Currently, only working on two plotting functions associated with torsion angle distribution (scatter plot) called by torsions and fractional secondary structure (overlaid line graph) called by sscalc. Modular inspirations from https://github.com/joaomcteixeira/taurenmd/pull/60

menoliu commented 2 years ago

Thanks for the comment Joao, I've implemented a way to auto-scale the x-axis tick increments based on the figure size. Of course, we can change these parameters as well in CLI :)

menoliu commented 2 years ago

@joaomcteixeira it's fixed! Plotting torsions is more flexible now

joaomcteixeira commented 2 years ago

Almost there! If I run the torsions on the conformers generated by the example, I get this:

· idpconfgen torsions conformer_*.pdb -o idpconfgen_database.json --plot colors='b','r'
[2022-05-24 11:40:11,300]Extracting Torsion Angles:
[2022-05-24 11:40:11,300]Reading Input Paths:
[2022-05-24 11:40:11,300]Logging Non-Existent Files:
[2022-05-24 11:40:11,300]
[2022-05-24 11:40:11,300]    done
[2022-05-24 11:40:11,301]    done
 100.0% 10/10 on 1 cpus |███████████████████████████████████████████████████████████████████|
[2022-05-24 11:40:11,332]Plotting Torsion Angle Distribution:
[2022-05-24 11:40:11,332]    Reminder: PDBs must be conformers of the same protein-system.
Traceback (most recent call last):
  File "/home/joao/anaconda3/envs/idpconfgen/bin/idpconfgen", line 33, in <module>
    sys.exit(load_entry_point('idpconfgen', 'console_scripts', 'idpconfgen')())
  File "/home/joao/github/idpconfgen/src/idpconfgen/cli.py", line 121, in maincli
    cmd.func(**vars(cmd))
  File "/home/joao/github/idpconfgen/src/idpconfgen/cli_torsions.py", line 205, in main
    errs=plot_torsions(max_residues, angles, degrees, n_confs, **tor_defaults)
  File "/home/joao/github/idpconfgen/src/idpconfgen/components/plots/plotfuncs.py", line 107, in plot_torsions
    xticks = np.arange(0,residues, increment)
ZeroDivisionError: division by zero
menoliu commented 2 years ago

Great catch @joaomcteixeira! Nice limit test. It's been fixed.

joaomcteixeira commented 2 years ago

We use to say in Portugal: "the devil knows more because he's old and because he's the devil" :smiling_imp:

joaomcteixeira commented 2 years ago

This is better because type is also a reserved word in python and we should not use it for variable names.

joaomcteixeira commented 2 years ago

I tested this locally and everything seems working. Do you agree on merging?

menoliu commented 2 years ago

Yes let's merge @joaomcteixeira