Home > testing > unit_tests > mafftTests.m

mafftTests

PURPOSE ^

run this test case with the command

SYNOPSIS ^

function tests = mafftTests

DESCRIPTION ^

run this test case with the command
results = runtests('mafftTests.m')

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %run this test case with the command
0002 %results = runtests('mafftTests.m')
0003 function tests = mafftTests
0004 tests = functiontests(localfunctions);
0005 end
0006 
0007 function testMafft(testCase)
0008 %This unit test comprises the functionality test for MAFFT in RAVEN:
0009 % 1. Check for resulting file against the expected one.
0010 
0011 %%
0012 %Get the directory for RAVEN Toolbox
0013 [ST, I]=dbstack('-completenames');
0014 ravenPath=fileparts(fileparts(fileparts(ST(I).file)));
0015 
0016 %Import structure that contains expected MAFFT results
0017 sourceDir = fileparts(which(mfilename));
0018 load([sourceDir,'/test_data/expCdhitMafftOutput.mat'],'expCdhitMafftOutput');
0019 
0020 %Generate temporary names for working directory and outFile
0021 tmpDIR=tempname;
0022 outFile=tempname;
0023 
0024 %Run MAFFT multi-threaded to use all logical cores assigned to MATLAB
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 %Create a temporary folder and copy multi-FASTA file there
0031 [~, ~]=system(['mkdir "' tmpDIR '"']);
0032 
0033 sourceDir = fileparts(which(mfilename));
0034 copyfile(fullfile(sourceDir,'test_data','yeast_galactosidases.fa'),tmpDIR);
0035 
0036 %%
0037 %Run protein multi-sequence alignment with MAFFT
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     % Define WSL paths
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 %Open actual MAFFT results file
0052 actMafftOutput=importdata(fullfile(outFile));
0053 
0054 %Remove the old tempfiles
0055 delete([outFile '*']);
0056 
0057 %Remove temporary folder, since testing is finished
0058 [~, ~]=system(['rm "' tmpDIR '" -r']);
0059 
0060 %%
0061 %Check 1a: Check if files for MAFFT results are the same
0062 verifyEqual(testCase,actMafftOutput,expCdhitMafftOutput);
0063 
0064 %Check 1b: Change actual MAFFT results file and check if test fails
0065 actMafftOutput='abc';
0066 verifyNotEqual(testCase,actMafftOutput,expCdhitMafftOutput);
0067 end

Generated by m2html © 2005