public int getNumMappedReads(String path){
        int numReads = 0;
        try {
            //TextFile filtSam = new TextFile(path.replace(fnamePattern, "accepted_hits.filtered.sam"), false);
            //filtSam.open();
            //BufferedReader filtSam = new BufferedReader(new FileReader(path.replace(fnamePattern, "accepted_hits.filtered.sam")));
            TextFile filtSam;
            if (alnFnamePattern.isEmpty())
                filtSam = new TextFile(path.replace(fnamePattern, "accepted_hits.filtered.sam"), false);
            else if (alnFnamePattern.endsWith(".sam")){
                filtSam = new TextFile(path.replace(fnamePattern, alnFnamePattern), false);
                String line ="";

                while ( (line = filtSam.readLine()) != null){
                    if (! line.startsWith("@")){
                        numReads++;
                    }
                }
                filtSam.close();
            }
            else if (alnFnamePattern.endsWith("idxstats")){
                TextFile stats = new TextFile(path.replace(fnamePattern, alnFnamePattern), false);
                
                String[] els;
                while ((els = stats.readLineElems(TextFile.tab)) != null){
                    numReads += Integer.parseInt(els[2]);
                }
                stats.close();
            }
            //System.out.println("number of mapped reads: " + numReads);
            
        } catch (IOException ex) {
            Logger.getLogger(ProcessTranscriptCounts.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("No alignment file or summary file (" + alnFnamePattern + ") for " + path);
        }
        return numReads;
    }