|
| 1 | +function chrTable=chr2idx(inputParam) |
| 2 | +%preprocessTumorOnly - creates data structures for tumor only calling |
| 3 | +%calls parsePileupData.packed.pl to parse samtools output |
| 4 | +% |
| 5 | +% Syntax: [T, E]=preprocessTumorOnly(inputParam,paramFile) |
| 6 | +% |
| 7 | +% Inputs: |
| 8 | +% inputParam - data structure with the following fields: regionsFile, |
| 9 | +% numCPU, outname, blockSize, snpVCFpath, snpVCFname, |
| 10 | +% workingDirectory, tabixPath, NormalBase |
| 11 | +% |
| 12 | +% Outputs: |
| 13 | +% T - table of data by position |
| 14 | +% E - table of data by exon |
| 15 | +% |
| 16 | +% Other m-files required: none |
| 17 | +% Other requirements: parsePileupData.packed.pl, samtools, htslib |
| 18 | +% Subfunctions: none |
| 19 | +% MAT-files required: none |
| 20 | +% |
| 21 | +% See also: TumorOnlyWrapper |
| 22 | + |
| 23 | +% Author: Rebecca F. Halperin, PhD |
| 24 | +% Translational Genomics Research Institute |
| 25 | + |
| 26 | +% Website: https://github.com/tgen |
| 27 | +% Last revision: 3-June-2016 |
| 28 | + |
| 29 | +%------------- BEGIN CODE -------------- |
| 30 | + |
| 31 | +%[status,out]=system('printenv') |
| 32 | +%profile('-memory','on'); |
| 33 | +%profile on; |
| 34 | + |
| 35 | +sexChr=regexprep(inputParam.sexChr,'''','') |
| 36 | +sexChr=regexp(sexChr,',','split') |
| 37 | +if max(cellfun('length',sexChr))==0 |
| 38 | + chrList=cellstr(num2str(inputParam.autosomes','%-d')) |
| 39 | +else |
| 40 | + chrList=[cellstr(num2str(inputParam.autosomes','%-d')); sexChr']; |
| 41 | +end |
| 42 | + |
| 43 | +[~,out]=system(['samtools view -H `head -n1 ' inputParam.bamList ' ` | grep ^@SQ']); |
| 44 | + |
| 45 | +contigs=strtok(extractAfter(strsplit(out,'\n'),'SN:')); |
| 46 | + |
| 47 | +[lia,locb]=ismember(chrList,contigs); |
| 48 | + |
| 49 | +chrTable=table(); |
| 50 | +chrTable.chrName=chrList(lia); |
| 51 | +chrTable.chrIdx=locb(lia); |
| 52 | + |
| 53 | +if sum(~lia)>0 |
| 54 | + message=['warning chr ' strjoin(chrList(~lia),',') ' not found in bam'] |
| 55 | +end |
0 commit comments