summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/matlab/quikr.m23
-rw-r--r--src/matlab/quikrCustomTrained.m18
-rw-r--r--src/matlab/quikrTrain.m8
3 files changed, 12 insertions, 37 deletions
diff --git a/src/matlab/quikr.m b/src/matlab/quikr.m
index d24596e..f43ae8f 100644
--- a/src/matlab/quikr.m
+++ b/src/matlab/quikr.m
@@ -12,21 +12,12 @@ function xstar = quikr(inputfasta)
%orientation, so as a preprocessing step, make sure everything is in the
%forward (+) orientation.
if nargin>1
- error('too many input arguments');
-end
-if (isunix && not(ismac)) %If linux, use ./count-linux
- [status, counts]=unix(['./count-linux -r 6 -1 -u ' inputfasta]); %count the 6-mers in the fasta file, in the forward direction, return the counts without labels
- if status ~= 0
- error('./count-linux failed: ensure count-linux is an executable. Try chmod a+rx count-linux. Be sure matlab/octave is in the same directory as count-linux');
- end
-elseif ismac %If mac, then use ./count-osx
- [status, counts]=unix(['./count-osx -r 6 -1 -u ' inputfasta]); %count the 6-mers in the fasta file, in the forward direction, return the counts without labels
- if status ~= 0
- error('./count-osx failed: ensure count-linux is an executable. Try chmod a+rx count-osx. Be sure matlab/octave is in the same directory as count-osx');
- end
-elseif ispc
- error('Windows is not yet supported');
-end
+ error('too many input arguments');
+
+[status, counts]=unix(['count-kmers -r 6 -1 -u ' inputfasta]); %count the 6-mers in the fasta file, in the forward direction, return the counts without labels
+if status ~= 0
+ error('count-kmers failed: ensure count-kmers is in your path.');
+
counts=textscan(counts,'%f'); %convert into floats
counts=counts{:}; %make into a vector
counts=counts/sum(counts); %form a probability vector from the counts
@@ -49,4 +40,4 @@ end %Matlab automatically reads it in correctly, just need to rename it
warning off
xstar=lsqnonneg(Aaux,yaux); %perform the nonnegative least squares
warning on
-xstar=xstar/sum(xstar); %transform the output into a probability vector. Note this vector is on the same basis as Aaux, so the entries correspond to sequences in trainset7_112011.fa \ No newline at end of file
+xstar=xstar/sum(xstar); %transform the output into a probability vector. Note this vector is on the same basis as Aaux, so the entries correspond to sequences in trainset7_112011.fa
diff --git a/src/matlab/quikrCustomTrained.m b/src/matlab/quikrCustomTrained.m
index b58aa31..c7961c7 100644
--- a/src/matlab/quikrCustomTrained.m
+++ b/src/matlab/quikrCustomTrained.m
@@ -15,19 +15,9 @@ if rws~=4^k
error('Wrong k-mer size for input training matrix');
end
-if (isunix && not(ismac))
- [status, counts]=unix([sprintf('./count-linux -r %d -1 -u ',k) ' ' inputfasta]); %count the 6-mers in the fasta file, in the forward direction, return the counts without labels.
- if status ~= 0
- error('./count-linux failed: ensure count-linux is an executable. Try chmod a+rx count-linux. Be sure matlab/octave is in the same directory as count-linux');
- end
-elseif ismac
- [status, counts]=unix([sprintf('./count-osx -r %d -1 -u ',k) ' ' inputfasta]); %count the 6-mers in the fasta file, in the forward direction, return the counts without labels.
- if status ~= 0
- error('./count-osx failed: ensure count-linux is an executable. Try chmod a+rx count-osx. Be sure matlab/octave is in the same directory as count-osx');
- end
-elseif ispc
- error('Windows is not yet supported');
-end
+[status, counts]=unix(['count-kmers -r 6 -1 -u ' inputfasta]); %count the 6-mers in the fasta file, in the forward direction, return the counts without labels
+if status ~= 0
+ error('count-kmers failed: ensure count-kmers is in your path.');
counts=textscan(counts,'%f'); %read them in as floats.
counts=counts{:};
@@ -39,4 +29,4 @@ Aaux=[ones(1,clumns);lambda*trainingmatrix]; %form the k-mer sensing matrix
warning off
xstar=lsqnonneg(Aaux,yaux); %perform the non-negative lease squares
warning on
-xstar=xstar/sum(xstar); %return the results as a probability vector \ No newline at end of file
+xstar=xstar/sum(xstar); %return the results as a probability vector
diff --git a/src/matlab/quikrTrain.m b/src/matlab/quikrTrain.m
index 7960cca..abdba95 100644
--- a/src/matlab/quikrTrain.m
+++ b/src/matlab/quikrTrain.m
@@ -21,13 +21,7 @@ outputfilename=fullfile(pathtofile, [filename sprintf('-sensingmatrixK%d.txt',k)
kmerfilename=sprintf('%dmers.txt',k); %This contains the list of 6-mers to count. In future versions this will be computed locally instead of being read in.
-if (isunix && not(ismac)) %this is for the linux version
- unix(['./probabilities-by-read-linux ' sprintf('%d',k) ' ' inputfasta ' ' kmerfilename ' > ' outputfilename]); %obtain the k-mer counts of the inputfasta read-by-read
-elseif ismac %mac version
- unix(['./probabilities-by-read-osx ' sprintf('%d',k) ' ' inputfasta ' ' kmerfilename ' > ' outputfilename]); %obtain the k-mer counts of the inputfasta read-by-read
-elseif ispc %No PC version
- error('Windows is not yet supported');
-end
+unix(['probabilities-by-read ' sprintf('%d',k) ' ' inputfasta ' ' kmerfilename ' > ' outputfilename]); %obtain the k-mer counts of the inputfasta read-by-read
fid=fopen(outputfilename); %open the output file