
org.snpeff.fileIterator.SamFileIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SnpEff Show documentation
Show all versions of SnpEff Show documentation
Variant annotation and effect prediction package.
The newest version!
package org.snpeff.fileIterator;
import java.io.IOException;
import java.util.Iterator;
import org.snpeff.sam.SamEntry;
import org.snpeff.sam.SamHeader;
/**
* Reads a SAM file
* Note: This is a very 'rustic' reader (we should use Picard's API instead)
*
* @author pcingola
*/
public class SamFileIterator extends FileIterator {
public static boolean debug = false;
SamHeader headers;
public SamFileIterator(String samFileName) {
super(samFileName);
headers = new SamHeader();
}
public SamHeader getHeaders() {
return headers;
}
@Override
public Iterator iterator() {
return this;
}
/**
* Read a sequence from the file
* @return
*/
@Override
protected SamEntry readNext() {
try {
while((line = reader.readLine()) != null) {
lineNum++;
if( line.startsWith("@") ) headers.addHeaderRecord(line);
else return new SamEntry(line);
}
} catch(IOException e) {
return null;
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy