(mocassin_prot.m: last updated on December 31, 2014)
(README: last updated on February 25, 2016)

####################################################
TESTED:
Linux, MacOS X, and Windows
#####################################################


####################################################
FUNCTION: mocassin_prot(r, mdir, sdir)


Example Usages:

mocassin_prot(55, 'test/Matrices/', 'test/Primary_Solutions/')
####################################################


####################################################
PREPARATION: (DO THIS BEFORE YOU RUN THE SCRIPT)

Working directory MUST contain the following script (included in the package):
        mocassin_prot.m
	proteinlinearprogram.m
	
MATLAB's Optimization and Parallel Computing Toolboxes must be installed on the system. If Parallel Computing Toolbox is not installed, the program can still be run by commenting out lines 24 and 195.
	
The scoring (distance) tables for the proteins should already exist as .txt files and labeled as 1_mtx.txt, 2_mtx.txt, etc in a single directory. mtxassemble.pl generates these matrices in the "Matrices" directory. The path to this directory is given in the second argument (mdir).

All output files are saved in the directory specified in the third argument (sdir). This directory needs to be created before running mocassin-prot. For convenience, mtxassemble.pl will create a directory "Primary_Solutions" to be used for this purpose. If a different directory is desired, create it and provide its path as the third argument.

Sample inputs and outputs can be found in the exampleData directory.

SPECIAL NOTES:
** If Matlab has trouble executing the parallel computing package try using the following command before running the program:
distcomp.feature( 'LocalUseMpiexec', false )

** If using MATLAB version 2013 or older you will need to change line 24 to: matlabpool
and line 195 to: matlabpool(close)

####################################################


####################################################
INPUTS:  r = the number of proteins in the network (i.e. how many scoring matrices
             exist)
         mdir = the directory where the distance matrices are stored
         sdir = the directory where the solution data files are to be stored

####################################################
How to run mocassin_prot.m:

[Using MATLAB GUI]
- Start MATLAB by double clicking on the MATLAB icon (or type "matlab" in Linux)
- Change the "Current Folder" to the MOCASSIN_prot working directory
- In Linux (or similar) environment, use "cd" command to change the directory
- In the "Command Window" type:
  >> mocassin_prot(55, 'test/Matrices/', 'test/Primary_Solutions/')
- Hit return

[From the command-line]
In Linux you can run mocassin-prot.m directly from the command-line. First move to the MOCASSIN_prot working directory. Then run mocassin_prot.m as follows:
matlab -nodesktop -nosplash -logfile log -r "mocassin_prot(55, 'test/Matrices/', 'test/Primary_Solutions/'); exit"

'-logfile' option specifies the log file ("log" in the above example)


In MacOS X, MATLAB can be run in Terminal as follows:
/Applications/MATLAB_R2015b.app/bin/matlab -nodesktop -nosplash -logfile log -r "mocassin_prot(55, 'test/Matrices/', 'test/Primary_Solutions/'); exit"

Note that the appropriate MATLAB version name needs to be used instead f "MATLAB_R2015b.app" in the example above.  




####################################################
OUTPUT FILES: all the files mentioned below will be written to the output directory chosen by the "sdir" option

1. SolutionK.mat
--------------------------
Matrices (in .mat format) that give the LP solution information. 

The first row (minus the 1,1) matrix entry) gives the conservation probability vector and the first
column (minus the (1,1) matrix entry) gives the diversity weight vector. The game value is in the (3,3) cell of the matrix. 
Note that if the protein only has one domain then the third row of the matrix will still be added. The solution .mat file
labeled SolutionK.mat is the solution for the distance matrix K_mtx.txt. If there was no solution (the LP didn't converge, etc.)
then the output .mat file will contain no matrix and will have the string variable g = 'no solution'

2. SolutionK.txt
--------------------------
Same solution matrix as described above but stored as a text file.
####################################################