Package net.sf.picard.util

Examples of net.sf.picard.util.SamLocusIterator


//        int end = 247199724;
        Interval interval = new Interval(chr_id, start, end);
        IntervalList il = new IntervalList(samReader.getFileHeader());
        il.add(interval);
       
        SamLocusIterator sli = new SamLocusIterator(samReader, il, true);

        FileWriter fw = new FileWriter("/data/kimjh/WGS/simulation_test_chr1/seperate_10p/gatk/depth_diff.txt");
        BufferedWriter bw = new BufferedWriter(fw);

        for (Iterator<SamLocusIterator.LocusInfo> iter = sli.iterator(); iter.hasNext();) {
            SamLocusIterator.LocusInfo locusInfo = iter.next();
            List recordList = locusInfo.getRecordAndPositions();
            Iterator it = recordList.iterator();
            String readBase = "";
            String baseQuality = "";
            while(it.hasNext()){
                SamLocusIterator.RecordAndOffset record = (SamLocusIterator.RecordAndOffset) it.next();
                if(baseQuality.equals("")){
//                    readBase += Byte.toString(record.getReadBase());
//                    baseQuality += record.getBaseQuality();
                    readBase += (char)(record.getReadBase()&0xff);
                    baseQuality += (int)((record.getBaseQuality()));
                }else{
                    readBase += ","+(char)(record.getReadBase()&0xff);
                    baseQuality += ","+(int)((record.getBaseQuality()));
                }
            }

            System.out.println("chr1\t"+locusInfo.getPosition()+"\t"+locusInfo.getRecordAndPositions().size()+"\t"+readBase+"\t"+baseQuality+"\n");
//            bw.write("chr1\t"+locusInfo.getPosition()+"\t"+locusInfo.getRecordAndPositions().size()+"\n");
            int pos = locusInfo.getPosition();
            int size = locusInfo.getRecordAndPositions().size();

            if (temp != null) {
                t = temp.split("\t");
                int sam_pos = Integer.parseInt(t[1]);
                int sam_size = Integer.parseInt(t[2]);

                while (sam_pos <= pos && temp != null) {
                    t = temp.split("\t");
                    sam_pos = Integer.parseInt(t[1]);
                    sam_size = Integer.parseInt(t[2]);
                    if (sam_pos == pos) {
                        if (sam_size != size) {
                            if(pos%1000000==0){
                                System.out.println(pos);
                            }                           
                            bw.write(pos + "\t" + size + "\t" + sam_size + "\n");
                        }
                        temp = br.readLine();
                    } else if(sam_pos>pos){                       
                    }else{
                        temp = br.readLine();
                    }
                }
            }
        }
        br.close();
        fr.close();

        bw.flush();
        bw.close();
        fw.close();

        sli.close();
        samReader.close();
    }
View Full Code Here


        IntervalList il = new IntervalList(samReader.getFileHeader());
        il.add(interval);

        ArrayList locusList = new ArrayList();

        SamLocusIterator sli = new SamLocusIterator(samReader, il, true);
        for (Iterator<SamLocusIterator.LocusInfo> iter = sli.iterator(); iter.hasNext();) {
            SamLocusIterator.LocusInfo locusInfo = iter.next();
            List recordList = locusInfo.getRecordAndPositions();

            Locus loc = new Locus();
            loc.setChr(getChr());
            loc.setPos(locusInfo.getPosition());
            loc.setDepth(recordList.size());
            loc.setMeanQualities(recordList);

            locusList.add(loc);
        }

        setLociValues(locusList, overlappedAreaList);
        sli.close();
    }
View Full Code Here

TOP

Related Classes of net.sf.picard.util.SamLocusIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.