setQuality

Update quality information

Description

example

newObject = setQuality(object,qualityInfo) returns a new object that is a copy of object with the Quality property set to qualityInfo.

example

newObject = setQuality(object,qualityInfo,subset) returns a new object that is a copy of object with the Quality property of a subset of elements set to qualityInfo. A one-to-one relationship must exist between the number and order of elements in qualityInfo and subset.

Examples

collapse all

Store read data from a SAM-formatted file in a BioRead object. Set 'InMemory' to true to load the object into memory so that you can modify its properties.

br = BioRead('SRR005164_1_50.fastq','InMemory',true)
br = 
  BioRead with properties:

     Quality: {50x1 cell}
    Sequence: {50x1 cell}
      Header: {50x1 cell}
       NSeqs: 50
        Name: ''

Check the quality information for the first three elements of the object.

br.Quality(1:3)
ans = 3x1 cell array
    {'<A<<@=+><'<<<<>8<>8<<<>;&<=7>8=9#<;<?9<<<<?9<<<<A;<<A<<<@:<<<<>7<?<)<;A;'                                                                                                     }
    {'A<<<;<<<<@:<<<;;A;;A;@=*<<<<A>+<<<A;<<<<<<;;;<;<<@;@9<;<<B<B?.@9<@:A>,<?<)<<<A<<B@81*"<<<<A<A=A<<<<;<<<<<;<<:<<<?8@:8<@:<A;?8'                                                }
    {'<<<<<<;A;<<<<@=*:?9CA90(<6;9;<;<;A<<<;B<<B@5&<;<<A;:A<<B@/A;<<;:<<@:;<;<<<;?9<<<<<<;<:;<1<CA7)7<CA7+990;;9@;A<<;:69B=<1<CA6'<9CA1<@;:>77:?<)<<A;<>8;A==6A<9A?-;@:<B?.A;+;<<:<'}

Generate random quality scores for the first three reads. Assume that the quality scores are between 0 (equivalent to the ASCII code of 33) and 60 (equivalent to the ASCII code of 93).

qualities = cell(3,1);
rng('default');
for i = 1:3
    qualities{i} = char(floor((93 - 33) * rand(1,length(br.Quality{i}))) + 33);
end
qualities
qualities = 3x1 cell array
    {'QW(WF&1AZZ*[Z>Q):WPZH#SYINM8H+K"1#&RJ4Z#;7NP,>;GKN1IH*(>Z5D.N0?JVZA))0S0'                                                                                                     }
    {'Q/X5,0E=6RDAX2NN7C%$@OY(C=!5*P3@*E0HJM<&.W*RA\%;'Z!ORU&80Q:W+0))UCA)TF6?9%/(,/:#WY>>5W7'O8/9&(YZC$/6R!#+GLG<A2M,J,7FO%XO>;;3?'                                                }
    {'?RPG7Q@6YUBFD-3=.S,.+.;3X:,W[;'09D0EK.(24:?&0Q"XL>C/<ZA@.>FI87\#VWP&05I)L'H>OKWV5J,"M?=WEFTQC+/V">+[K?=$I#%@&RRL)H@[GQ<:R&(+8RQ$8@:HF2:!\+'7,>5ZX$M1:AY:[3KHAJH+(\+"BUI,7<[*T'}

Update the quality information of the first three elements. br2 is a copy of br with the updated quality scores. If you need to update the br object itself, set it as the output of the function.

br2 = setQuality(br,qualities,[1:3]);
br2.Quality(1:3)
ans = 3x1 cell array
    {'QW(WF&1AZZ*[Z>Q):WPZH#SYINM8H+K"1#&RJ4Z#;7NP,>;GKN1IH*(>Z5D.N0?JVZA))0S0'                                                                                                     }
    {'Q/X5,0E=6RDAX2NN7C%$@OY(C=!5*P3@*E0HJM<&.W*RA\%;'Z!ORU&80Q:W+0))UCA)TF6?9%/(,/:#WY>>5W7'O8/9&(YZC$/6R!#+GLG<A2M,J,7FO%XO>;;3?'                                                }
    {'?RPG7Q@6YUBFD-3=.S,.+.;3X:,W[;'09D0EK.(24:?&0Q"XL>C/<ZA@.>FI87\#VWP&05I)L'H>OKWV5J,"M?=WEFTQC+/V">+[K?=$I#%@&RRL)H@[GQ<:R&(+8RQ$8@:HF2:!\+'7,>5ZX$M1:AY:[3KHAJH+(\+"BUI,7<[*T'}

You can update the quality scores of the br object directly by using dot notation.

br.Quality(1:3) = qualities;
br.Quality(1:3)
ans = 3x1 cell array
    {'QW(WF&1AZZ*[Z>Q):WPZH#SYINM8H+K"1#&RJ4Z#;7NP,>;GKN1IH*(>Z5D.N0?JVZA))0S0'                                                                                                     }
    {'Q/X5,0E=6RDAX2NN7C%$@OY(C=!5*P3@*E0HJM<&.W*RA\%;'Z!ORU&80Q:W+0))UCA)TF6?9%/(,/:#WY>>5W7'O8/9&(YZC$/6R!#+GLG<A2M,J,7FO%XO>;;3?'                                                }
    {'?RPG7Q@6YUBFD-3=.S,.+.;3X:,W[;'09D0EK.(24:?&0Q"XL>C/<ZA@.>FI87\#VWP&05I)L'H>OKWV5J,"M?=WEFTQC+/V">+[K?=$I#%@&RRL)H@[GQ<:R&(+8RQ$8@:HF2:!\+'7,>5ZX$M1:AY:[3KHAJH+(\+"BUI,7<[*T'}

Input Arguments

collapse all

Object containing the read data, specified as a BioRead or BioMap object. If the object is not stored in memory, you cannot modify its properties, except the Name property.

Example: readData

Quality information of reads, specified as a cell array of character vectors or string vector.

Example: {'<A<<@=+>','A<<<;<<'}

Subset of elements in the object, specified as a vector of positive integers, logical vector, string vector, or cell array of character vectors containing valid sequence headers.

Example: [1 3]

Tip

When you use a sequence header (or a cell array of headers) for subset, a repeated header specifies all elements with that header.

Output Arguments

collapse all

New object with updated properties, returned as a BioRead or BioMap object.

Introduced in R2010a