changed the warning that is outputted when the GenomeLoc constructor can't find the given contig in the reference.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@913 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2009-06-05 15:49:03 +00:00
parent 092a754071
commit 199be46c36
3 changed files with 20 additions and 4 deletions

View File

@ -284,7 +284,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
}
catch( MalformedGenomeLocException ex ) {
if( firstFailure ) {
Utils.warnUser("Failed to parse contig on line '" + line + "'. Skipping ahead to the next recognized GenomeLoc.");
Utils.warnUser("Failed to parse contig on line '" + line + "'. The reason given was: " + ex.getMessage() + " Skipping ahead to the next recognized GenomeLoc. ");
firstFailure = false;
}
if( !parser.hasNext() )

View File

@ -137,7 +137,7 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Cloneable {
*/
public static GenomeLoc parseGenomeLoc( final String contig, long start, long stop ) {
if( !isContigValid(contig) )
throw new MalformedGenomeLocException("Contig " + contig + " is not within installed in the GATK sequence dictionary derived from the reference.");
throw new MalformedGenomeLocException("Contig " + contig + " does not match any contig in the GATK sequence dictionary derived from the reference.");
return new GenomeLoc(contig,start,stop);
}
@ -198,7 +198,7 @@ public class GenomeLoc implements Comparable<GenomeLoc>, Cloneable {
}
if( !isContigValid(contig) )
throw new MalformedGenomeLocException("Contig " + contig + " is not within installed in the GATK sequence dictionary derived from the reference.");
throw new MalformedGenomeLocException("Contig " + contig + " does not match any contig in the GATK sequence dictionary derived from the reference.");
GenomeLoc loc = parseGenomeLoc(contig,start,stop);
// System.out.printf(" => Parsed location '%s' into %s%n", str, loc);

View File

@ -29,7 +29,7 @@ public class Utils {
logger.warn(String.format("********************************************************************************"));
logger.warn(String.format("* WARNING:"));
logger.warn(String.format("*"));
logger.warn(String.format("* %s", msg));
prettyPrintWarningMessage(msg);
logger.warn(String.format("********************************************************************************"));
}
@ -43,6 +43,22 @@ public class Utils {
throw new RuntimeException(msg);
}
/**
* pretty print the warning message supplied
* @param message the message
*/
private static void prettyPrintWarningMessage(String message) {
StringBuilder builder = new StringBuilder(message);
while (builder.length() > 70) {
int space = builder.lastIndexOf(" ", 70);
if (space <= 0) space = 70;
logger.warn(String.format("* %s", builder.substring(0,space)));
builder.delete(0,space + 1);
}
logger.warn(String.format("* %s", builder));
}
public static SAMFileWriter createSAMFileWriterWithCompression(SAMFileHeader header, boolean presorted, String file, int compression) {
if (file.endsWith(".bam"))
return new SAMFileWriterFactory().makeBAMWriter(header, presorted, new File(file), compression);