bioNetwork

PURPOSE ^

BIONETWORK load graph matrix from filePath and return a network structure

SYNOPSIS ^

function [ network ] = bioNetwork( filePath, dataType )

DESCRIPTION ^

 BIONETWORK load graph matrix from filePath and return a network structure

   [ network ] = bioNetwork( filePath, dataType )
   This function load graph matrix from filePath and return a network structure

   Input:
       filePath: path of file which could be txt or mat file
       dataType: 'normal' = txt file, 'mat' = mat file

   Output:
       network: a network structure

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [ network ] = bioNetwork( filePath, dataType )
0002 % BIONETWORK load graph matrix from filePath and return a network structure
0003 %
0004 %   [ network ] = bioNetwork( filePath, dataType )
0005 %   This function load graph matrix from filePath and return a network structure
0006 %
0007 %   Input:
0008 %       filePath: path of file which could be txt or mat file
0009 %       dataType: 'normal' = txt file, 'mat' = mat file
0010 %
0011 %   Output:
0012 %       network: a network structure
0013 
0014 %   ---------
0015 %   Yen-Nan Lin, NTHU, 2010-2014, Matlab 2012a
0016 
0017 data = [];
0018 if strcmp(dataType, 'normal')
0019     fileID = fopen(filePath, 'r');
0020     while ~feof(fileID)
0021         strLine = fgetl(fileID);
0022         numericLine = strread(strLine, '%d');
0023         data = [ data; numericLine' ];
0024     end
0025     fclose(fileID);
0026 elseif strcmp(dataType, 'mat')
0027     matFile = load(filePath);
0028     data = matFile.graphMatrix;
0029 end
0030 network = struct('data', sparse(data), 'size', length(data(:,1)) );
0031 network = make(network);
0032 end
0033 
0034 function [ network ] = make( network )
0035 network.matrix = sparse(network.size, network.size);
0036 network.matrix = network.data;
0037 network.label = 1:(network.size);
0038 end
0039

Generated on Thu 30-Jan-2014 00:00:07 by m2html © 2005