From d115209e8602cdeb4aed978e54b5c81d048decf8 Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 27 Mar 2009 13:27:04 +0000 Subject: [PATCH] moved a bunch of files over to the logging system. In some cases I ballparked the severity level of an error, so if you see something wrong feel free to make changes. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@209 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/gatk/GenomeAnalysisTK.java | 18 +- .../sting/gatk/TraversalEngine.java | 2 +- .../sting/gatk/WalkerManager.java | 188 ++++++++++-------- .../gatk/iterators/LocusIteratorByHanger.java | 28 ++- .../gatk/iterators/ReferenceIterator.java | 12 +- 5 files changed, 145 insertions(+), 103 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisTK.java b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisTK.java index 8a41163e5..50cad2126 100644 --- a/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisTK.java +++ b/java/src/org/broadinstitute/sting/gatk/GenomeAnalysisTK.java @@ -230,17 +230,17 @@ public class GenomeAnalysisTK extends CommandLineProgram { final String startContigName = startContig.getSequenceName(); for ( SAMSequenceRecord targetContig : refFile.getSequenceDictionary().getSequences() ) { refFile.seekToContig(startContigName, true); - System.out.printf("Seeking: current=%s, target=%s%n", startContigName, targetContig.getSequenceName()); + logger.info(String.format("Seeking: current=%s, target=%s%n", startContigName, targetContig.getSequenceName())); long lastTime = System.currentTimeMillis(); final boolean success = refFile.seekToContig(targetContig.getSequenceName(), true); long curTime = System.currentTimeMillis(); final double elapsed = (curTime - lastTime) / 1000.0; timings.add(elapsed); - System.out.printf(" -> Elapsed time %.2f, averaging %.2f sec / seek for %d seeks%n", - elapsed, Utils.averageDouble(timings), timings.size()); + logger.info(String.format(" -> Elapsed time %.2f, averaging %.2f sec / seek for %d seeks%n", + elapsed, Utils.averageDouble(timings), timings.size())); if ( ! success ) { - System.out.printf("Failured to seek to %s from %s%n", targetContig.getSequenceName(), lastContig ); + logger.error(String.format("Failured to seek to %s from %s%n", targetContig.getSequenceName(), lastContig )); } //System.exit(1); } @@ -297,14 +297,14 @@ public class GenomeAnalysisTK extends CommandLineProgram { int i = 0; String prevNextContigName = null; - System.out.printf("Walking reference sequence:%n"); + logger.info(String.format("Walking reference sequence:%n")); for ( SAMSequenceRecord refContig: refContigs ) { long curTime = System.currentTimeMillis(); ReferenceSequence contig = refFile.nextSequence(); final double elapsed = (curTime - lastTime) / 1000.0; timings.add(elapsed); - System.out.printf("%2d : expected %s contig, found %s with next of %s after %.2f seconds, average is %.2f%n", i, - refContig.getSequenceName(), contig.getName(), refFile.getNextContigName(), elapsed, Utils.averageDouble(timings)); + logger.info(String.format("%2d : expected %s contig, found %s with next of %s after %.2f seconds, average is %.2f%n", i, + refContig.getSequenceName(), contig.getName(), refFile.getNextContigName(), elapsed, Utils.averageDouble(timings))); if ( prevNextContigName != null && contig.getName() != null && ! prevNextContigName.equals(contig.getName()) ) throw new RuntimeIOException(String.format("Unexpected contig ordering %s was expected next, but I found %s?", prevNextContigName, contig.getName())); @@ -313,8 +313,8 @@ public class GenomeAnalysisTK extends CommandLineProgram { lastTime = curTime; i++; - System.out.printf(" Traversing from chr1 to %s would require jumping %d bytes%n", - contig.getName(), refFile.getDistanceBetweenContigs("chr1", contig.getName())); + logger.info(String.format(" Traversing from chr1 to %s would require jumping %d bytes%n", + contig.getName(), refFile.getDistanceBetweenContigs("chr1", contig.getName()))); } } } diff --git a/java/src/org/broadinstitute/sting/gatk/TraversalEngine.java b/java/src/org/broadinstitute/sting/gatk/TraversalEngine.java index 82f19ee7e..46ef0b546 100755 --- a/java/src/org/broadinstitute/sting/gatk/TraversalEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/TraversalEngine.java @@ -332,7 +332,7 @@ public class TraversalEngine { */ protected void printOnTraversalDone(final String type, T sum) { printProgress(true, type, null); - System.out.println("Traversal reduce result is " + sum); // TODO: fixme -- how do we use this logger? + logger.info("Traversal reduce result is " + sum); final long curTime = System.currentTimeMillis(); final double elapsed = (curTime - startTime) / 1000.0; logger.info(String.format("Total runtime %.2f secs, %.2f min, %.2f hours%n", elapsed, elapsed / 60, elapsed / 3600)); diff --git a/java/src/org/broadinstitute/sting/gatk/WalkerManager.java b/java/src/org/broadinstitute/sting/gatk/WalkerManager.java index 03658a1da..360f1d435 100755 --- a/java/src/org/broadinstitute/sting/gatk/WalkerManager.java +++ b/java/src/org/broadinstitute/sting/gatk/WalkerManager.java @@ -23,6 +23,7 @@ import java.util.jar.JarInputStream; import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.gatk.walkers.WalkerName; import org.broadinstitute.sting.utils.cmdLine.Argument; +import org.apache.log4j.Logger; /** * Created by IntelliJ IDEA. @@ -33,43 +34,49 @@ import org.broadinstitute.sting.utils.cmdLine.Argument; */ public class WalkerManager { - private Map walkers; - - public WalkerManager( String pluginDirectory ) { + /** + * our log, which we want to capture anything from this class + */ + private static Logger logger = Logger.getLogger(WalkerManager.class); + + private Map walkers; + + public WalkerManager(String pluginDirectory) { try { List walkerCandidates = new ArrayList(); // Load all classes that live in this jar. final File location = getThisLocation(); - walkerCandidates.addAll( loadClassesFromLocation( location ) ); + walkerCandidates.addAll(loadClassesFromLocation(location)); // Load all classes that live in the extension path. - if(pluginDirectory == null) + if (pluginDirectory == null) pluginDirectory = location.getParent() + File.separator + "walkers"; - System.out.println("plugin directory: " + pluginDirectory); + logger.info("plugin directory: " + pluginDirectory); - File extensionPath = new File( pluginDirectory ); - if(extensionPath.exists()) { - List filesInPath = findFilesInPath( extensionPath, "", "class", false ); - walkerCandidates.addAll( loadExternalClasses( extensionPath, filesInPath ) ); + File extensionPath = new File(pluginDirectory); + if (extensionPath.exists()) { + List filesInPath = findFilesInPath(extensionPath, "", "class", false); + walkerCandidates.addAll(loadExternalClasses(extensionPath, filesInPath)); } walkerCandidates = filterWalkers(walkerCandidates); - if(walkerCandidates.isEmpty()) - throw new RuntimeException("No walkers were found."); + if (walkerCandidates.isEmpty()) + throw new RuntimeException("No walkers were found."); - walkers = createWalkerDatabase( walkerCandidates ); + walkers = createWalkerDatabase(walkerCandidates); } // IOExceptions here are suspect; they indicate that the WalkerManager can't open its containing jar. // Wrap in a RuntimeException. - catch(IOException ex) { + catch (IOException ex) { throw new RuntimeException(ex); } } /** * Does a walker with the given name exist? + * * @param walkerName Name of the walker for which to search. * @return True if the walker exists, false otherwise. */ @@ -79,29 +86,31 @@ public class WalkerManager { /** * Gets a walker with the given name, or null if no walker exists. + * * @param walkerName Name of the walker to retrieve. * @return The walker object if found; null otherwise. */ public Walker createWalkerByName(String walkerName) throws InstantiationException, IllegalAccessException { Class walker = walkers.get(walkerName); - return (Walker)walker.newInstance(); + return (Walker) walker.newInstance(); } - public Class getWalkerClassByName( String walkerName ) { + public Class getWalkerClassByName(String walkerName) { return walkers.get(walkerName); } /** * Determines which jar file contains the WalkerManager class. + * * @return Jar file containing the WalkerManager class. */ private File getThisLocation() throws IOException { try { java.net.URI locationURI = getClass().getProtectionDomain().getCodeSource().getLocation().toURI(); - return new File( locationURI ); + return new File(locationURI); } - catch(java.net.URISyntaxException ex) { + catch (java.net.URISyntaxException ex) { // a URISyntaxException here must be an IO error; wrap as such. throw new IOException(ex); } @@ -109,23 +118,25 @@ public class WalkerManager { /** * Load classes internal to the classpath from an arbitrary location. + * * @param location Location from which to load classes. * @return List of classes. * @throws IOException Problem occurred reading classes. */ - private List loadClassesFromLocation( File location ) - throws IOException { - if( location.getAbsolutePath().endsWith(".jar") ) - return loadClassesFromJar( location ); + private List loadClassesFromLocation(File location) + throws IOException { + if (location.getAbsolutePath().endsWith(".jar")) + return loadClassesFromJar(location); else { - List classFileNames = findFilesInPath( location, "", "class", true ); - return loadInternalClasses( classFileNames ); + List classFileNames = findFilesInPath(location, "", "class", true); + return loadInternalClasses(classFileNames); } } /** * Loads concrete classes from a jar which are both in the same package or 'sub-package' of baseClass, * and which extend from baseClass. + * * @param jarFile The jar file to search. * @return A list of classes derived from baseClass. */ @@ -133,22 +144,21 @@ public class WalkerManager { throws IOException { List subclasses = new ArrayList(); - JarInputStream jarInputStream = new JarInputStream(new FileInputStream( jarFile ) ); + JarInputStream jarInputStream = new JarInputStream(new FileInputStream(jarFile)); try { JarEntry jarEntry = jarInputStream.getNextJarEntry(); - while(jarEntry != null) { + while (jarEntry != null) { String jarEntryName = jarEntry.getName(); - if(jarEntryName.endsWith(".class")) - { + if (jarEntryName.endsWith(".class")) { String className = fileNameToClassName(jarEntryName); - subclasses.add( Class.forName(className) ); + subclasses.add(Class.forName(className)); } jarEntry = jarInputStream.getNextJarEntry(); } } - catch(ClassNotFoundException ex) { + catch (ClassNotFoundException ex) { // A ClassNotFoundException here must be an IO error; wrap as such. throw new IOException(ex); } @@ -161,23 +171,24 @@ public class WalkerManager { /** * Loads a list of classes currently on the classpath. + * * @param classFileNames List of files representing classes. * @return class objects. * @throws IOException Unable to open any of the found classes. */ - private List loadInternalClasses( List classFileNames ) + private List loadInternalClasses(List classFileNames) throws IOException { List internalClasses = new ArrayList(); - for( String classFileName: classFileNames ) { - String className = fileNameToClassName( classFileName ); + for (String classFileName : classFileNames) { + String className = fileNameToClassName(classFileName); try { - internalClasses.add( Class.forName(className) ); + internalClasses.add(Class.forName(className)); } - catch(ClassNotFoundException ex) { + catch (ClassNotFoundException ex) { // A ClassNotFoundException here must be an IO error; wrap as such. throw new IOException(ex); - } + } } return internalClasses; @@ -185,6 +196,7 @@ public class WalkerManager { /** * Load loose classes, external to the classloader, from the specified directory. + * * @param path source path from which to load classes. * @return A list of all loose classes contained in the path directory. */ @@ -194,15 +206,15 @@ public class WalkerManager { URL pathURL = path.toURI().toURL(); - ClassLoader cl = new URLClassLoader(new URL[] { pathURL }); + ClassLoader cl = new URLClassLoader(new URL[]{pathURL}); - List filesInPath = findFilesInPath( path, "", "class", false ); - for( String file: filesInPath ) { - String className = fileNameToClassName( file ); + List filesInPath = findFilesInPath(path, "", "class", false); + for (String file : filesInPath) { + String className = fileNameToClassName(file); try { subclasses.add(cl.loadClass(className)); } - catch(ClassNotFoundException ex) { + catch (ClassNotFoundException ex) { // Class not found from a list of classes just looked up is an IO error. Wrap and throw. throw new IOException(ex); } @@ -213,26 +225,27 @@ public class WalkerManager { /** * Find the files in the given directory matching the given extension. - * @param basePath Path to search. + * + * @param basePath Path to search. * @param relativePrefix What directory should the given files be presented relative to? - * @param extension Extension for which to search. - * @param recursive Search recursively. Beware of symlinks! + * @param extension Extension for which to search. + * @param recursive Search recursively. Beware of symlinks! * @return A list of files matching the specified criteria. - * TODO: Move to a utils class. - * TODO: Test recursive traversal in the presence of a symlink. + * TODO: Move to a utils class. + * TODO: Test recursive traversal in the presence of a symlink. */ private List findFilesInPath(final File basePath, final String relativePrefix, final String extension, boolean recursive) { List filesInPath = new ArrayList(); - File[] contents = basePath.listFiles( new OrFilenameFilter( new DirectoryFilter(), new ExtensionFilter( extension ) ) ); - for( File content: contents ) { + File[] contents = basePath.listFiles(new OrFilenameFilter(new DirectoryFilter(), new ExtensionFilter(extension))); + for (File content : contents) { String relativeFileName = relativePrefix.trim().length() != 0 ? - relativePrefix + File.separator + content.getName() : - content.getName(); - if ( relativeFileName.endsWith(extension) ) + relativePrefix + File.separator + content.getName() : + content.getName(); + if (relativeFileName.endsWith(extension)) filesInPath.add(relativeFileName); - else if( content.isDirectory() && recursive ) - filesInPath.addAll( findFilesInPath( content, relativeFileName, extension, recursive ) ); + else if (content.isDirectory() && recursive) + filesInPath.addAll(findFilesInPath(content, relativeFileName, extension, recursive)); } return filesInPath; @@ -241,12 +254,13 @@ public class WalkerManager { /** * Convert a filename of the form a/b/c.class to a.b.c. Makes no assurances about whether the * class is valid on any classloader. + * * @param fileName Filename to convert. * @return classname represented by that file. - * TODO: Move to a utils class. + * TODO: Move to a utils class. */ - private String fileNameToClassName( String fileName ) { - return fileName.substring(0,fileName.lastIndexOf(".class")).replace('/','.'); + private String fileNameToClassName(String fileName) { + return fileName.substring(0, fileName.lastIndexOf(".class")).replace('/', '.'); } /** @@ -255,29 +269,45 @@ public class WalkerManager { */ private class ExtensionFilter implements FilenameFilter { private String extensionName = null; - public ExtensionFilter( String extensionName ) { this.extensionName = extensionName; } - public boolean accept( File f, String s ) { return s.endsWith("." + extensionName); } + + public ExtensionFilter(String extensionName) { + this.extensionName = extensionName; + } + + public boolean accept(File f, String s) { + return s.endsWith("." + extensionName); + } } private class DirectoryFilter implements FilenameFilter { - public boolean accept( File f, String s ) { return new File( f, s ).isDirectory(); } + public boolean accept(File f, String s) { + return new File(f, s).isDirectory(); + } } private class OrFilenameFilter implements FilenameFilter { private FilenameFilter lhs = null, rhs = null; - public OrFilenameFilter( FilenameFilter lhs, FilenameFilter rhs ) { this.lhs = lhs; this.rhs = rhs; } - public boolean accept( File f, String s ) { return lhs.accept( f, s ) || rhs.accept( f, s ); } + + public OrFilenameFilter(FilenameFilter lhs, FilenameFilter rhs) { + this.lhs = lhs; + this.rhs = rhs; + } + + public boolean accept(File f, String s) { + return lhs.accept(f, s) || rhs.accept(f, s); + } } /** * Given a list of classes, return a list of those classes which extend from the Walker base interface. + * * @param classes Arbitrary list of classes. * @return List of classes extending from Walker. */ private List filterWalkers(List classes) { StdReflect reflect = new JdkStdReflect(); - FunctionN filterFunc = reflect.instanceFunction(new ClassFilter(Walker.class),"filter",Class.class); - return Functions.findAll(filterFunc.f1(),classes); + FunctionN filterFunc = reflect.instanceFunction(new ClassFilter(Walker.class), "filter", Class.class); + return Functions.findAll(filterFunc.f1(), classes); } /** @@ -291,24 +321,25 @@ public class WalkerManager { } public Boolean filter(Class clazz) { - return baseClass.isAssignableFrom( clazz ) && - !Modifier.isAbstract( clazz.getModifiers() ) && - !Modifier.isInterface( clazz.getModifiers() ); + return baseClass.isAssignableFrom(clazz) && + !Modifier.isAbstract(clazz.getModifiers()) && + !Modifier.isInterface(clazz.getModifiers()); } } /** * Instantiate the list of walker classes. Add them to the walker hashmap. + * * @param walkerClasses Classes to instantiate. * @return map of walker name to walker. */ - private Map createWalkerDatabase(List walkerClasses) { - Map walkers = new HashMap(); + private Map createWalkerDatabase(List walkerClasses) { + Map walkers = new HashMap(); - for(Class walkerClass : walkerClasses) { - String walkerName = getWalkerName( walkerClass ); - System.out.printf("* Adding module %s%n", walkerName); - walkers.put(walkerName,walkerClass); + for (Class walkerClass : walkerClasses) { + String walkerName = getWalkerName(walkerClass); + logger.info(String.format("* Adding module %s%n", walkerName)); + walkers.put(walkerName, walkerClass); } return walkers; @@ -316,19 +347,20 @@ public class WalkerManager { /** * Create a name for this type of walker. + * * @param walkerType The type of walker. * @return A name for this type of walker. */ - public static String getWalkerName( Class walkerType ) { + public static String getWalkerName(Class walkerType) { String walkerName = ""; - if( walkerType.getAnnotation( WalkerName.class ) != null ) - walkerName = walkerType.getAnnotation( WalkerName.class ).value().trim(); + if (walkerType.getAnnotation(WalkerName.class) != null) + walkerName = walkerType.getAnnotation(WalkerName.class).value().trim(); - if( walkerName.length() == 0 ) { + if (walkerName.length() == 0) { walkerName = walkerType.getSimpleName(); - if( walkerName.endsWith("Walker") ) - walkerName = walkerName.substring( 0,walkerName.lastIndexOf("Walker") ); + if (walkerName.endsWith("Walker")) + walkerName = walkerName.substring(0, walkerName.lastIndexOf("Walker")); } return walkerName; diff --git a/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByHanger.java b/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByHanger.java index 664a0368e..276adb5c7 100755 --- a/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByHanger.java +++ b/java/src/org/broadinstitute/sting/gatk/iterators/LocusIteratorByHanger.java @@ -13,12 +13,18 @@ import org.broadinstitute.sting.utils.RefHanger; import org.broadinstitute.sting.gatk.iterators.PushbackIterator; import org.broadinstitute.sting.gatk.iterators.LocusIterator; import org.broadinstitute.sting.gatk.LocusContext; +import org.apache.log4j.Logger; /** * Iterator that traverses a SAM File, accumulating information on a per-locus basis */ public class LocusIteratorByHanger extends LocusIterator { + /** + * our log, which we want to capture anything from this class + */ + private static Logger logger = Logger.getLogger(LocusIteratorByHanger.class); + // ----------------------------------------------------------------------------------------------------------------- // // member fields @@ -58,19 +64,19 @@ public class LocusIteratorByHanger extends LocusIterator { RefHanger.Hanger rhanger = readHanger.getHanger(i); RefHanger.Hanger ohanger = offsetHanger.getHanger(i); - System.out.printf(" -> %s:", rhanger.loc); + logger.debug(String.format(" -> %s:", rhanger.loc)); for ( int j = 0; j < rhanger.size(); j++ ) { SAMRecord read = (SAMRecord)rhanger.get(j); int offset = (Integer)ohanger.get(j); - System.out.printf(" %s(%d)=%s", read.getReadName(), offset, read.getReadString().charAt(offset) ); + logger.debug(String.format(" %s(%d)=%s", read.getReadName(), offset, read.getReadString().charAt(offset) )); } - System.out.printf("%n"); + logger.debug(String.format("%n")); } } public void clear() { - System.out.printf("clear() called%n"); + logger.debug(String.format(("clear() called%n"))); readHanger.clear(); offsetHanger.clear(); } @@ -96,7 +102,7 @@ public class LocusIteratorByHanger extends LocusIterator { expandWindow(INCREMENT_SIZE); if ( DEBUG ) { - System.out.printf("in Next:%n"); + logger.debug(String.format(("in Next:%n"))); printState(); } @@ -120,13 +126,13 @@ public class LocusIteratorByHanger extends LocusIterator { for ( AlignmentBlock block : read.getAlignmentBlocks() ) { if ( DEBUG ) - System.out.printf("Processing block %s len=%d%n", block, block.getLength()); + logger.debug(String.format("Processing block %s len=%d%n", block, block.getLength())); for ( int i = 0; i < block.getLength(); i++ ) { GenomeLoc offset = new GenomeLoc(readLoc.getContig(), block.getReferenceStart() + i); readHanger.expandingPut(offset, read); offsetHanger.expandingPut(offset, block.getReadStart() + i - 1); if ( DEBUG ) - System.out.printf(" # Added %s%n", offset); + logger.debug(String.format(" # Added %s%n", offset)); } } } @@ -158,13 +164,13 @@ public class LocusIteratorByHanger extends LocusIterator { private final void expandWindow(final int incrementSize) { if ( DEBUG ) { - System.out.printf("entering expandWindow..., hasNext=%b%n", it.hasNext()); + logger.debug(String.format("entering expandWindow..., hasNext=%b%n", it.hasNext())); printState(); } while ( it.hasNext() ) { if ( DEBUG ) { - System.out.printf("Expanding window%n"); + logger.debug(String.format("Expanding window%n")); printState(); } @@ -173,12 +179,12 @@ public class LocusIteratorByHanger extends LocusIterator { GenomeLoc readLoc = Utils.genomicLocationOf(read); if ( DEBUG ) { - System.out.printf(" Expanding window sizes %d with %d : left=%s, right=%s, readLoc = %s, cmp=%d%n", + logger.debug(String.format(" Expanding window sizes %d with %d : left=%s, right=%s, readLoc = %s, cmp=%d%n", readHanger.size(), incrementSize, readHanger.hasHangers() ? readHanger.getLeftLoc() : "NA", readHanger.hasHangers() ? readHanger.getRightLoc() : "NA", readLoc, - readHanger.hasHangers() ? readLoc.compareTo(readHanger.getLeftLoc()) : -100); + readHanger.hasHangers() ? readLoc.compareTo(readHanger.getLeftLoc()) : -100)); } //if ( readHanger.size() >= incrementSize ) { //if ( readHanger.hasHangers() && readLoc.compareTo(readHanger.getLeftLoc()) == 1) { diff --git a/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java b/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java index 2a149e7b9..80d34fe3e 100755 --- a/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java +++ b/java/src/org/broadinstitute/sting/gatk/iterators/ReferenceIterator.java @@ -11,6 +11,7 @@ import java.io.IOException; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.FastaSequenceFile2; +import org.apache.log4j.Logger; /** * Created by IntelliJ IDEA. @@ -34,7 +35,10 @@ public class ReferenceIterator implements Iterator { public ReferenceIterator( FastaSequenceFile2 refFile ) { this.refFile = refFile; } - + /** + * our log, which we want to capture anything from this class + */ + private static Logger logger = Logger.getLogger(ReferenceIterator.class); // -------------------------------------------------------------------------------------------------------------- // // Accessing data @@ -68,7 +72,7 @@ public class ReferenceIterator implements Iterator { public ReferenceIterator next() { if ( currentContig != null ) { - if ( DEBUG ) System.out.printf(" -> %s:%d %d%n", currentContig.getName(), offset, currentContig.length()); + if ( DEBUG ) logger.debug(String.format(" -> %s:%d %d%n", currentContig.getName(), offset, currentContig.length())); } offset++; // move on to the next position @@ -139,7 +143,7 @@ public class ReferenceIterator implements Iterator { if ( currentContig == null ) next(); - if ( DEBUG ) System.out.printf(" -> Seeking to %s %d from %s %d%n", seekContigName, seekOffset, currentContig.getName(), offset); + if ( DEBUG ) logger.debug(String.format(" -> Seeking to %s %d from %s %d%n", seekContigName, seekOffset, currentContig.getName(), offset)); int cmpContigs = GenomeLoc.compareContigs(seekContigName, currentContig.getName()); @@ -150,7 +154,7 @@ public class ReferenceIterator implements Iterator { } else if ( cmpContigs == 1 ) { // we need to jump forward - if ( DEBUG ) System.out.printf(" -> Seeking in the fasta file to %s from %s%n", seekContigName, currentContig.getName()); + if ( DEBUG ) logger.debug(String.format(" -> Seeking in the fasta file to %s from %s%n", seekContigName, currentContig.getName())); if ( ! refFile.seekToContig(seekContigName) ) { // ok, do the seek // a false result indicates a failure, throw a somewhat cryptic call