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

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


####################################################
FUNCTION:
mocassin_prot_iter(r, mdir, sdir1, sdir2)


Example Usages:

mocassin_prot_iter(55, 'test/Matrices/', 'test/Primary_Solutions/', 'test/Secondary_Solutions/')

mocassin_prot_iter(55, 'test/Matrices/', 'test/Secondary_Solutions/', 'test/Tertiary_Solutions/')
####################################################


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

Working directory MUST contain the following script (included in the package):
        mocassin_prot_iter.m
	proteinlinearprogram.m
	
MATLAB's Optimization Toolbox must be installed on the system.
	
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 matrix files in the "Matrices" directory. The path to this directory is given in the second argument (mdir).

The outputs from MOCASSIN-prot primary (or previous iteration of MOCASSIN-prot) run should already exist as .mat files and be stored in a single directory. The path to this directory is given in the third argument (sdir1).

All output files are saved in the directory specified by the fourth argument (sdir2). This directory needs to be created before running mocassin_prot_iter.

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

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


####################################################
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
         sdir1 = the directory where the primary solution data files are stored
         sdir2 = the directory where the secondary solution data files are to be stored

####################################################
How to run mocassin_prot_iter.m:

See READMEmocassin_prot.txt


####################################################
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.
####################################################