0001
0002
0003 function tests = cdhitTests
0004 tests = functiontests(localfunctions);
0005 end
0006
0007 function testCdhit(testCase)
0008
0009
0010
0011
0012
0013 [ST, I]=dbstack('-completenames');
0014 ravenPath=fileparts(fileparts(fileparts(ST(I).file)));
0015
0016
0017 if isunix
0018 if ismac
0019 binEnd='.mac';
0020 else
0021 binEnd='';
0022 end
0023 elseif ispc
0024 binEnd='.exe';
0025 else
0026 dispEM('Unknown OS, exiting.')
0027 return
0028 end
0029
0030
0031 sourceDir = fileparts(which(mfilename));
0032 load([sourceDir,'/test_data/expCdhitMafftOutput.mat'],'expCdhitMafftOutput');
0033
0034
0035 tmpDIR=tempname;
0036 outFile=tempname;
0037
0038
0039 cores = evalc('feature(''numcores'')');
0040 cores = strsplit(cores, 'MATLAB was assigned: ');
0041 cores = regexp(cores{2},'^\d*','match');
0042 cores = cores{1};
0043
0044
0045 [~, ~]=system(['mkdir "' tmpDIR '"']);
0046
0047 sourceDir = fileparts(which(mfilename));
0048 copyfile(fullfile(sourceDir,'test_data','yeast_galactosidases.fa'),tmpDIR);
0049
0050
0051
0052 if ispc
0053
0054 wslPath.fastaFile=getWSLpath([tmpDIR filesep 'yeast_galactosidases.fa']);
0055 wslPath.outFile=getWSLpath(outFile);
0056 wslPath.cdhit=getWSLpath(fullfile(ravenPath,'software','cd-hit','cd-hit'));
0057 [~, ~]=system(['wsl "' wslPath.cdhit '" -T "' num2str(cores) '" -i "' wslPath.fastaFile '" -o "' wslPath.outFile '" -c 1.0 -n 5 -M 2000']);
0058 else
0059 [~, ~]=system(['"' fullfile(ravenPath,'software','cd-hit',['cd-hit' binEnd]) '" -T "' num2str(cores) '" -i "' fullfile(tmpDIR, 'yeast_galactosidases.fa') '" -o "' outFile '" -c 1.0 -n 5 -M 2000']);
0060 end
0061
0062
0063
0064 actCdhitOutput=importdata(fullfile(outFile));
0065
0066
0067 delete([outFile '*']);
0068
0069
0070 [~, ~]=system(['rm "' tmpDIR '" -r']);
0071
0072
0073
0074 verifyEqual(testCase,actCdhitOutput,expCdhitMafftOutput);
0075
0076
0077 actCdhitOutput='abc';
0078 verifyNotEqual(testCase,actCdhitOutput,expCdhitMafftOutput);
0079 end