0001
0002
0003 function tests = mafftTests
0004 tests = functiontests(localfunctions);
0005 end
0006
0007 function testMafft(testCase)
0008
0009
0010
0011
0012
0013 [ST, I]=dbstack('-completenames');
0014 ravenPath=fileparts(fileparts(fileparts(ST(I).file)));
0015
0016
0017 sourceDir = fileparts(which(mfilename));
0018 load([sourceDir,'/test_data/expCdhitMafftOutput.mat'],'expCdhitMafftOutput');
0019
0020
0021 tmpDIR=tempname;
0022 outFile=tempname;
0023
0024
0025 cores = evalc('feature(''numcores'')');
0026 cores = strsplit(cores, 'MATLAB was assigned: ');
0027 cores = regexp(cores{2},'^\d*','match');
0028 cores = cores{1};
0029
0030
0031 [~, ~]=system(['mkdir "' tmpDIR '"']);
0032
0033 sourceDir = fileparts(which(mfilename));
0034 copyfile(fullfile(sourceDir,'test_data','yeast_galactosidases.fa'),tmpDIR);
0035
0036
0037
0038 if ismac
0039 [~, ~]=system(['"' fullfile(ravenPath,'software','mafft','mafft-mac','mafft.bat') '" --auto --anysymbol --thread "' num2str(cores) '" "' fullfile(tmpDIR, 'yeast_galactosidases.fa') '" > "' outFile '"']);
0040 elseif isunix
0041 [~, ~]=system(['"' fullfile(ravenPath,'software','mafft','mafft-linux64','mafft.bat') '" --auto --anysymbol --thread "' num2str(cores) '" "' fullfile(tmpDIR, 'yeast_galactosidases.fa') '" > "' outFile '"']);
0042 elseif ispc
0043
0044 wslPath.fastaFile=getWSLpath([tmpDIR filesep 'yeast_galactosidases.fa']);
0045 wslPath.outFile=getWSLpath(outFile);
0046 wslPath.mafft=getWSLpath(fullfile(ravenPath,'software','mafft','mafft-linux64','mafft.bat'));
0047 [~, ~]=system(['wsl "' wslPath.mafft '" --auto --anysymbol --quiet --thread "' num2str(cores) '" --out "' wslPath.outFile '" "' wslPath.fastaFile '"']);
0048 end
0049
0050
0051
0052 actMafftOutput=importdata(fullfile(outFile));
0053
0054
0055 delete([outFile '*']);
0056
0057
0058 [~, ~]=system(['rm "' tmpDIR '" -r']);
0059
0060
0061
0062 verifyEqual(testCase,actMafftOutput,expCdhitMafftOutput);
0063
0064
0065 actMafftOutput='abc';
0066 verifyNotEqual(testCase,actMafftOutput,expCdhitMafftOutput);
0067 end