Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/0.0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjohnwright committed Aug 31, 2015
2 parents 6d03d65 + 35ab4d0 commit 84e6350
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 752 deletions.
31 changes: 17 additions & 14 deletions c_interface/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ int mymain(int em_max_iterations, int em_number_of_training_samples, double em_l
char pairwise_filepath[200];
char pathway_filepath[200];
char observed_data_filepath[200];
char input4columns_filepath[200];
char pairwise_interactions_filepath[200];
char hyperparameters_filepath[200];
char estimated_parameters_filepath[200];
char posterior_probabilities_filepath[200];

ini_gets("files", "pairwise", "dummy", pairwise_filepath, sizearray(value), ini_filename);
ini_gets("files", "pathway", "dummy", pathway_filepath, sizearray(value), ini_filename);
ini_gets("files", "observed_data", "dummy", observed_data_filepath, sizearray(value), ini_filename);
ini_gets("files", "input_four_columns", "dummy", input4columns_filepath, sizearray(value), ini_filename);
ini_gets("files", "pairwise_interactions", "dummy", pairwise_interactions_filepath, sizearray(value), ini_filename);
ini_gets("files", "hyperparameters", "dummy", hyperparameters_filepath, sizearray(value), ini_filename);
ini_gets("files", "estimated_parameters", "dummy", estimated_parameters_filepath, sizearray(value), ini_filename);
ini_gets("files", "posterior_probabilities", "dummy", posterior_probabilities_filepath, sizearray(value), ini_filename);
Expand All @@ -48,16 +48,17 @@ int mymain(int em_max_iterations, int em_number_of_training_samples, double em_l
printf("Pathway filepath not specified in config\n");
return 1;
}
if ( strcmp(input4columns_filepath, "dummy") == 0 ) {
printf("Input4column filepath not specified in config\n");
if ( strcmp(pairwise_interactions_filepath, "dummy") == 0 ) {
printf("Pairwise interactions filepath not specified in config\n");
return 1;
}

reaction_logic_to_factorgraph(input4columns_filepath, pathway_filepath, number_of_states);
int exit_code = reaction_logic_to_factorgraph(pairwise_interactions_filepath, pathway_filepath, number_of_states);

int exit_code = 0;
if (exit_code != 0) {
printf("Failed to generate factorgraph (error_code: %d)\n", exit_code);
char * strerr = strerror(exit_code);
printf("Failed to generate factorgraph (error code: %d): %s\n", exit_code, strerr);
return exit_code;
}
else {
printf("\tFactorgragh has been output into the following pathway file: %s\n", pathway_filepath);
Expand All @@ -80,10 +81,11 @@ int mymain(int em_max_iterations, int em_number_of_training_samples, double em_l
return 1;
}

learning_discrete_BayNet(pathway_filepath, observed_data_filepath, estimated_parameters_filepath, number_of_states, em_max_iterations, em_log_likelihood_change_limit, MAP_flag);
int exit_code = 0;
int exit_code = learning_discrete_BayNet(pathway_filepath, observed_data_filepath, estimated_parameters_filepath, number_of_states, em_max_iterations, em_log_likelihood_change_limit, MAP_flag);
if (exit_code != 0) {
printf("Learning failed (error_code: %d)\n", exit_code);
char * strerr = strerror (exit_code);
printf("Learning failed (error code: %d): %s\n", exit_code, *strerr);
return 0;
}
else {
printf("\tEstimated Parameters habe been writtent to the following file: %s\n", estimated_parameters_filepath);
Expand All @@ -107,10 +109,11 @@ int mymain(int em_max_iterations, int em_number_of_training_samples, double em_l
return 1;
}

doLBPinference(pathway_filepath, observed_data_filepath, posterior_probabilities_filepath, number_of_states);
int error_code = 0;
if (error_code != 0) {
printf("Inference failed with error code %d\n", error_code);
int exit_code = doLBPinference(pathway_filepath, observed_data_filepath, posterior_probabilities_filepath, number_of_states);
if (exit_code != 0) {
char * strerr = strerror (exit_code);
printf("Inference failed with (error code: %d): %s\n", exit_code, *strerr);
return exit_code;
}
else {
printf("\tPosterior probabilities have been written to the following file: %s\n", posterior_probabilities_filepath);
Expand Down
2 changes: 1 addition & 1 deletion config/example.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[files]
pathway=../test/data1/JE_Network_FG.txt
observed_data=../test/data1/JE_network_dd.txt
input_four_columns=../test/data1/JE_Network.txt
pairwise_interactions=../test/data1/JE_Network.txt
hyperparameters=
posteriors=
node_posterior_probabilities=../test/data1/nodepost.txt
Expand Down
21 changes: 10 additions & 11 deletions net/include/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ typedef struct Node Node ;
double inAbsolute(double i);
int cstring_cmp(const void *a, const void *b);
int uniq(char *a[], int len);
int readCharFile(char * lines[],char *fileToRead,int maxbufflen);
int readCharFile(char * lines[],char *fileToRead,int maxbufflen, int *datalen);
void rad_normaliseC(double *T, int N);
void maxVector(double *maxV, int *maxIdx, double *v, int length_v);
int ExtractNonUniqNodeNum(char *filename);
int ExtractNonUniqNodelist(char *filename,char ** nodeName);
int ExtractNonUniqNodeNum(char *filename, int *numNode);
int ExtractNonUniqNodelist(char *filename,char ** nodeName, int *k);


void LogSplashLBP(double **factorarray,int **array,int *numComb,Node *AlarmNet,int num_state,int N,int Nv,int lu,int *iteration);
Expand All @@ -79,26 +79,25 @@ void belief_resBelief_Splash(double **factorarray, int **array,int *numComb,Node
void LogRBP(double **factorarray, int **array,int *numComb,Node *AlarmNet,int num_state,int N,int Nv,int lu,int *iteration);

int **makeCPTindex(Node *pGraph,int Nf,int Nv,int num_state);
int ReadObservedData(char *filename, double **obs_values, int **obs_Ids,int *numSample);
int ReadObservedData(char *filename, double **obs_values, int **obs_Ids,int *numSample, int *nmRNAObs);

int pairwiseTofactorgraph(char *readpairwisefilename,char * writefactorgraphfilename,int nstate);
int hashSourceTargetNodes(char *readpairwisefilename);
int hashSourceTargetNodes(char *readpairwisefilename, int * Nv);
int mod (int a, int b);
void normalizeCPD(double * f, double *CPD,int numComb,int num_state,int flag);
int FactorgraphFile_To_NodeStructures(char *pathway, Node *pGraph,int num_state,int Nv,int Nf);
int FactorgraphFile_To_NodeStructures(char *pathway, Node *pGraph,int num_state,int Nv,int Nf, int *lenMsgVec);

void inputBasedModifiedCPT(Node *pGraph,double ** factorarray, int *obs_values,int *obs_Ids, int **cpt, int Nv,int numObs,int flag );

void doLBPinference(char *pathway,char * obs_data,char *nodepost,int num_state);

int doLBPinference(char *pathway,char * obs_data,char *posterior_probabilities,int num_state);

int reaction_logic_to_factorgraph(char *readreactionlogicpathways,char * writefactorgraphfilename,int nstate);

int ReadMultipleVisibleSets(char *filename, double **obs_values, int **obs_Ids,int *numSample);
int ReadMultipleVisibleSets(char *filename, double **obs_values, int **obs_Ids,int *numSample, int *num_visibles);

void hash_graph_node_IDs(char *readreactionlogicpathways);

void learning_discrete_BayNet(char * pathway,char *obs_data,char *nodepost, int num_state, int max_num_repeat, double LLchangeLimit, int MAPflag);

int learning_discrete_BayNet(char * pathway,char *obs_data,char *nodepost, int num_state, int max_num_repeat, double LLchangeLimit, int MAPflag);
char *strerror_libnet(int error_code);

#endif
Loading

0 comments on commit 84e6350

Please sign in to comment.