classdef SeqTrimOptions < bioinfo.internal.FunctionOptions

    
    properties
        %METHOD and THRESHOLD specify the trimming criterion and threshold
        %   to apply to each sequence. Valid options for METHOD and
        %   THRESHOLD are as follows:
        %
        %      * "MaxNumberLowQualityBases": applies a maximum threshold on
        %      the number of low quality bases allowed before trimming any
        %      sequence. This is the default method. THRESHOLD = [V1 V2] is
        %      a numeric vector with two elements: the first element V1 is
        %      a non-negative number and specifies the maximum number of
        %      low quality bases allowed before trimming any sequence,
        %      starting at the 5' end; the second element V2 specifies the
        %      minimum base quality. Any base with quality less than V2 is
        %      considered a low quality base. THRESHOLD is interpreted
        %      according to the specified "Encoding" property and defaults
        %      to [0 10].
        %
        %      * "MaxPercentLowQualityBases": applies a maximum threshold
        %      on the percentage of low quality bases allowed before
        %      trimming any sequence. THRESHOLD = [V1 V2] is a numeric
        %      vector with two elements: the first element V1 is a
        %      non-negative number between 0 and 100, and specifies the
        %      maximum percentage of low quality bases allowed before
        %      trimming any sequence, starting at the 5' end; the second
        %      element V2 specifies the minimum base quality. Any base with
        %      quality less than V2 is considered a low quality base.
        %      THRESHOLD is interpreted according to the specified
        %      "Encoding" property and defaults to [0 10].
        %
        %      * "MeanQuality": applies a minimum threshold THRESHOLD on
        %      the running average base quality allowed before trimming any
        %      sequence, starting at the 5' end. The base quality and
        %      threshold THRESHOLD are interpreted according to the
        %      specified "Encoding" property. THRESHOLD is a numeric scalar
        %      and defaults to 0.
        %
        %      * "BasePositions": trims each sequence according to the
        %      positions (first base and last base) specified in THRESHOLD,
        %      starting at the 5' end. THRESHOLD is a vector with two
        %      non-negative integers. To trim only the 5' end of each
        %      sequence before position V1, use THRESHOLD = [V1, Inf]. To
        %      trim only the 3' end of each sequence after position V2, use
        %      THRESHOLD = [1 V2]. Default is THRESHOLD = [1 Inf], i.e.,
        %      each sequence is left untrimmed.
        %
        %      * "Termini": trims each sequence of as many bases as
        %      specified in THRESHOLD. THRESHOLD is a vector with two
        %      non-negative integers: the first element specifies the
        %      number of bases to trim off the 5' end of each sequence, and
        %      the second element specifies the number of bases to trim off
        %      the 3' end of each sequence. To trim V1 bases off the 5'
        %      terminus only, use THRESHOLD = [V1 0]. To trim V2 bases off
        %      the 3' terminus only, use V = [0 V2]. Default is THRESHOLD =
        %      [0 0], i.e., each sequence is left untrimmed.
        %
        %   Note that sequences resulting in empty sequences after trimming are
        %   saved in the output files as empty sequences.
        Method(1,1) string {mustBeMember(Method, ["MaxNumberLowQualityBases", "MaxPercentLowQualityBases","MeanQuality", "BasePositions", "Termini"])} = "MaxNumberLowQualityBases";
        
        %THRESHOLD specifies the threshold to apply to each sequence,
        %   relative to the METHOD. See METHOD for more information.
        %   Default is [0 10] when METHOD is "MaxNumberLowQualityBases".
        Threshold(1,:) double {mustBeNonnegative} = [0 10];
        
        %WINDOWSIZE specifies the size of a sliding window over which to
        %   apply the trimming criterion and threshold specified with
        %   'Method' and 'Threshold'. Any given sequence is trimmed before
        %   the first base of the window that would violate the given
        %   quality criterion. The sliding window can be applied to the
        %   following methods: "MaxNumberLowQualityBases",
        %   "MaxPercentLowQualityBases", and "MeanQuality". Sequences
        %   shorter than WINDOWSIZE bases are saved in the output file as
        %   empty sequences. WINDOWSIZE is a positive integer. Default is
        %   Inf.
        WindowSize(1,1) double {mustBePositive} = Inf;
        
        %ENCODING specifies the encoding format of the base quality in the
        %   input file. ENCODING is a string scalar. Valid options for
        %   ENCODING are: "Sanger", "Solexa, "Illumina13", "Illumina15", or
        %   "Illumina18". The default is "Illumina18".
        Encoding(1,1) string {mustBeMember(Encoding, ["Sanger", "Solexa", "Illumina13", "Illumina15", "Illumina18"])} = "Illumina18";
        
        %OUTPUTSUFFIX specifies the suffix to use in the output file
        %   name(s) before the file extension FASTQ. OUTSUFFIX is an ASCII
        %   string scalar. Default is "_trimmed".
        OutputSuffix(1,1) string = "_trimmed";
    end
    
    methods
        function obj = SeqTrimOptions(modOptions)
            % SEQTRIMOPTIONS create a bioinfo.pipeline.options.SeqTrimOptions object.
            % 
            %  s = SEQTRIMOPTIONS creates a SEQTRIMOPTIONS object
            %  with default property values.
            %
            %  s = SEQTRIMOPTIONS(..., 'PropertyName', Value) specifies
            %  optional name-value arguments to set the object properties.
            %  To see the list of object properties, enter the following:
            %  help bioinfo.pipeline.options.SeqTrimOptions.
            %
            %  Examples:
            %
            %  % Create the object with default values.
            %  import bioinfo.pipeline.options.SeqTrimOptions
            %  s = SeqTrimOptions;
            %
            %  % Create the object with name-value arguments.
            %  s = SeqTrimOptions("Method", "MeanQuality", "Threshold", 5)
            %
            % See also seqtrim, bioinfo.pipeline.blocks.SeqTrim, bioinfo.pipeline.options.SeqFilterOptions
            
            % All other construction is done in the base class
            
            arguments
                modOptions.?bioinfo.pipeline.options.SeqTrimOptions
            end
            
            obj@bioinfo.internal.FunctionOptions(modOptions);
        end
    end
end
% Copyright 2021 The MathWorks, Inc.

