From 5b80c92cb701c94b21dc6df17ba5396643750294 Mon Sep 17 00:00:00 2001 From: Geraldine Van der Auwera Date: Fri, 27 May 2016 12:19:59 -0400 Subject: [PATCH] Improved article linking in error messages --- .../engine/filters/MalformedReadFilter.java | 2 +- .../gatk/utils/exceptions/UserException.java | 32 +++++++++---------- .../gatk/utils/help/HelpConstants.java | 4 +-- .../gatk/utils/sam/ReadUtils.java | 6 ++-- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/filters/MalformedReadFilter.java b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/filters/MalformedReadFilter.java index bfb7adebd..95a65633f 100644 --- a/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/filters/MalformedReadFilter.java +++ b/public/gatk-engine/src/main/java/org/broadinstitute/gatk/engine/filters/MalformedReadFilter.java @@ -219,7 +219,7 @@ public class MalformedReadFilter extends ReadFilter { if (! filterReadsWithNCigar && !allowNCigars) { throw new UserException.UnsupportedCigarOperatorException( CigarOperator.N,read, - "If you are working with RNA-Seq data, see " + HelpConstants.articlePost("3891") + " for guidance. " + "If you are working with RNA-Seq data, see " + HelpConstants.articlePost(3891) + " for guidance. " + "If you choose to disregard those instructions, or for other uses, you have the option of either " + "filtering out all reads with operator " + CigarOperator.N + " in their CIGAR string" + " (add --" + FILTER_READS_WITH_N_CIGAR_ARGUMENT_FULL_NAME + " to your command line) or overriding this check (add -U " diff --git a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/exceptions/UserException.java b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/exceptions/UserException.java index 859437fb7..b29fb2a41 100644 --- a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/exceptions/UserException.java +++ b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/exceptions/UserException.java @@ -50,7 +50,7 @@ public class UserException extends ReviewedGATKException { /** * The URL where people can get help messages. Printed when an error occurs */ - public static final String PHONE_HOME_DOCS_URL = "http://gatkforums.broadinstitute.org/discussion/1250/what-is-phone-home-and-how-does-it-affect-me#latest"; + public static final String PHONE_HOME_DOCS_URL = HelpConstants.articlePost(1250); public UserException(String msg) { super(msg); } public UserException(String msg, Throwable e) { super(msg, e); } @@ -136,7 +136,7 @@ public class UserException extends ReviewedGATKException { public static class BadTmpDir extends UserException { public BadTmpDir(String message) { - super(String.format("An error occurred while working with the tmp directory %s. You can specify -Djava.io.tmpdir=X on the command line (before the -jar argument) where X is a directory path, to use a more appropriate temporary directory. The exact error was %s", System.getProperties().get("java.io.tmpdir"), message)); + super(String.format("An error occurred while working with the tmp directory %s. You can specify -Djava.io.tmpdir=X on the command line (before the -jar argument) where X is a directory path, to use a more appropriate temporary directory. Note that this is a JVM argument, not a GATK argument. The exact error was %s", System.getProperties().get("java.io.tmpdir"), message)); } } @@ -160,7 +160,7 @@ public class UserException extends ReviewedGATKException { public static class ErrorWritingBamFile extends UserException { public ErrorWritingBamFile(String message) { - super(String.format("An error occurred when trying to write the BAM file. Usually this happens when there is not enough space in the directory to which the data is being written (generally the temp directory) or when your system's open file handle limit is too small. Your system administrator can help you resolve these issues. If you know what temporary directory to use, you can specify it by adding -Djava.io.tmpdir=X to the command line (before the -jar argument), where X is the directory path. The exact error was %s", message)); + super(String.format("An error occurred when trying to write the BAM file. Usually this happens when there is not enough space in the directory to which the data is being written (generally the temp directory) or when your system's open file handle limit is too small. Your system administrator can help you resolve these issues. If you know what temporary directory to use, you can specify it by adding -Djava.io.tmpdir=X to the command line (before the -jar argument), where X is the directory path. Note that this is a JVM argument, not a GATK argument. The exact error was %s", message)); } } @@ -225,20 +225,20 @@ public class UserException extends ReviewedGATKException { public static class MissortedBAM extends UserException { public MissortedBAM(SAMFileHeader.SortOrder order, File file, SAMFileHeader header) { - super(String.format("Missorted input SAM/BAM/CRAM files: %s must be sorted in %s order but order was: %s. Please see " + HelpConstants.forumPost("discussion/1317/collected-faqs-about-input-files-for-sequence-read-data-bam-cram") + "for more information.", file, order, header.getSortOrder())); + super(String.format("Missorted input SAM/BAM/CRAM files: %s must be sorted in %s order but order was: %s. Please see " + HelpConstants.articlePost(1317) + "for more information.", file, order, header.getSortOrder())); } public MissortedBAM(SAMFileHeader.SortOrder order, String message) { - super(String.format("Missorted input SAM/BAM/CRAM files: files are not sorted in %s order. Please see " + HelpConstants.forumPost("discussion/1317/collected-faqs-about-input-files-for-sequence-read-data-bam-cram") + "for more information. Error details: %s", order, message)); + super(String.format("Missorted input SAM/BAM/CRAM files: files are not sorted in %s order. Please see " + HelpConstants.articlePost(1317) + "for more information. Error details: %s", order, message)); } public MissortedBAM(SAMFileHeader.SortOrder order, SAMRecord read, String message) { - super(String.format("Missorted input SAM/BAM/CRAM file %s: file sorted in %s order but %s is required. Please see " + HelpConstants.forumPost("discussion/1317/collected-faqs-about-input-files-for-sequence-read-data-bam-cram") + "for more information. Error details: %s", + super(String.format("Missorted input SAM/BAM/CRAM file %s: file sorted in %s order but %s is required. Please see " + HelpConstants.articlePost(1317) + "for more information. Error details: %s", read.getFileSource().getReader(), read.getHeader().getSortOrder(), order, message)); } public MissortedBAM(String message) { - super(String.format("Missorted input SAM/BAM/CRAM files. Please see " + HelpConstants.forumPost("discussion/1317/collected-faqs-about-input-files-for-sequence-read-data-bam-cram") + "for more information. Error details: %s", message)); + super(String.format("Missorted input SAM/BAM/CRAM files. Please see " + HelpConstants.articlePost(1317) + "for more information. Error details: %s", message)); } } @@ -252,7 +252,7 @@ public class UserException extends ReviewedGATKException { } public MalformedBAM(String source, String message) { - super(String.format("SAM/BAM/CRAM file %s is malformed. Please see " + HelpConstants.forumPost("discussion/1317/collected-faqs-about-input-files-for-sequence-read-data-bam-cram") + "for more information. Error details: %s", source, message)); + super(String.format("SAM/BAM/CRAM file %s is malformed. Please see " + HelpConstants.articlePost(1317) + "for more information. Error details: %s", source, message)); } } @@ -262,7 +262,7 @@ public class UserException extends ReviewedGATKException { } public MisencodedBAM(String source, String message) { - super(String.format("SAM/BAM/CRAM file %s appears to be using the wrong encoding for quality scores: %s. Please see https://www.broadinstitute.org/gatk/guide?id=6470 for more details and options related to this error.", source, message)); + super(String.format("SAM/BAM/CRAM file %s appears to be using the wrong encoding for quality scores: %s. Please see " + HelpConstants.articlePost(6470) + " for more details and options related to this error.", source, message)); } } @@ -294,13 +294,13 @@ public class UserException extends ReviewedGATKException { public static class ReadMissingReadGroup extends MalformedBAM { public ReadMissingReadGroup(final SAMRecord read) { - super(read, String.format("Read %s is missing the read group (RG) tag, which is required by the GATK. Please see " + HelpConstants.forumPost("discussion/59/companion-utilities-replacereadgroups to fix this problem"), read.getReadName())); + super(read, String.format("Read %s is missing the read group (RG) tag, which is required by the GATK. Please see " + HelpConstants.articlePost(59), read.getReadName())); } } public static class ReadHasUndefinedReadGroup extends MalformedBAM { public ReadHasUndefinedReadGroup(final SAMRecord read, final String rgID) { - super(read, String.format("Read %s uses a read group (%s) that is not defined in the BAM header, which is not valid. Please see " + HelpConstants.forumPost("discussion/59/companion-utilities-replacereadgroups to fix this problem"), read.getReadName(), rgID)); + super(read, String.format("Read %s uses a read group (%s) that is not defined in the BAM header, which is not valid. Please see " + HelpConstants.articlePost(59), read.getReadName(), rgID)); } } @@ -312,7 +312,7 @@ public class UserException extends ReviewedGATKException { public static class MissortedFile extends UserException { public MissortedFile(File file, String message, Exception e) { - super(String.format("Missorted input file: %s is must be sorted in coordinate order. Please see " + HelpConstants.forumPost("discussion/1317/collected-faqs-about-input-files-for-sequence-read-data-bam-cram") + "for more information. Error details: %s and got error %s", file, message, getMessage(e))); + super(String.format("Missorted input file: %s is must be sorted in coordinate order. Please see " + HelpConstants.articlePost(1317) + "for more information. Error details: %s and got error %s", file, message, getMessage(e))); } } @@ -366,14 +366,14 @@ public class UserException extends ReviewedGATKException { public static class IncompatibleSequenceDictionaries extends UserException { public IncompatibleSequenceDictionaries(String message, String name1, SAMSequenceDictionary dict1, String name2, SAMSequenceDictionary dict2) { - super(String.format("Input files %s and %s have incompatible contigs. Please see " + HelpConstants.forumPost("discussion/63/input-files-have-incompatible-contigs") + "for more information. Error details: %s.\n %s contigs = %s\n %s contigs = %s", + super(String.format("Input files %s and %s have incompatible contigs. Please see " + HelpConstants.articlePost(63) + "for more information. Error details: %s.\n %s contigs = %s\n %s contigs = %s", name1, name2, message, name1, ReadUtils.prettyPrintSequenceRecords(dict1), name2, ReadUtils.prettyPrintSequenceRecords(dict2))); } } public static class LexicographicallySortedSequenceDictionary extends UserException { public LexicographicallySortedSequenceDictionary(String name, SAMSequenceDictionary dict) { - super(String.format("Lexicographically sorted human genome sequence detected in %s. Please see " + HelpConstants.articlePost("1328") + "for more information. Error details: %s contigs = %s", + super(String.format("Lexicographically sorted human genome sequence detected in %s. Please see " + HelpConstants.articlePost(1328) + "for more information. Error details: %s contigs = %s", name, name, ReadUtils.prettyPrintSequenceRecords(dict))); } } @@ -409,7 +409,7 @@ public class UserException extends ReviewedGATKException { public MissingReferenceFaiFile( final File indexFile, final File fastaFile ) { super(String.format("Fasta index file %s for reference %s does not exist. Please see %s for help creating it.", indexFile.getAbsolutePath(), fastaFile.getAbsolutePath(), - HelpConstants.forumPost("discussion/1601/how-can-i-prepare-a-fasta-file-to-use-as-reference"))); + HelpConstants.articlePost(1601))); } } @@ -417,7 +417,7 @@ public class UserException extends ReviewedGATKException { public MissingReferenceDictFile( final File dictFile, final File fastaFile ) { super(String.format("Fasta dict file %s for reference %s does not exist. Please see %s for help creating it.", dictFile.getAbsolutePath(), fastaFile.getAbsolutePath(), - HelpConstants.forumPost("discussion/1601/how-can-i-prepare-a-fasta-file-to-use-as-reference"))); + HelpConstants.articlePost(1601))); } } diff --git a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/help/HelpConstants.java b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/help/HelpConstants.java index 6c7068b19..279af20ed 100644 --- a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/help/HelpConstants.java +++ b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/help/HelpConstants.java @@ -62,8 +62,8 @@ public class HelpConstants { return GATK_FORUM_URL + post; } - public static String articlePost(String id) { - return GATK_ARTICLE_URL + "?id=" + id; + public static String articlePost(Integer id) { + return GATK_ARTICLE_URL + "?id=" + id.toString(); } /** diff --git a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/sam/ReadUtils.java b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/sam/ReadUtils.java index 0cd84f5d9..75617e87d 100644 --- a/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/sam/ReadUtils.java +++ b/public/gatk-utils/src/main/java/org/broadinstitute/gatk/utils/sam/ReadUtils.java @@ -66,7 +66,7 @@ public class ReadUtils { public static Set getSAMFileSamples(final SAMFileHeader header) { if ( header == null ) { throw new IllegalArgumentException("Missing SAM file header. " + - "For more information on read groups, see " + HelpConstants.articlePost("6472")); + "For more information on read groups, see " + HelpConstants.articlePost(6472)); } // get all of the unique sample names @@ -74,13 +74,13 @@ public class ReadUtils { final List readGroups = header.getReadGroups(); if ( readGroups == null ) { throw new UserException("SAM file header is missing the Read Group (@RG). " + - "For more information on read groups, see " + HelpConstants.articlePost("6472")); + "For more information on read groups, see " + HelpConstants.articlePost(6472)); } for ( final SAMReadGroupRecord readGroup : readGroups ) { final String sample = readGroup.getSample(); if ( sample == null ) { throw new UserException("SAM file header is missing the sample field (SM) in the Read Group (@RG). " + - "For more information on read groups, see " + HelpConstants.articlePost("6472")); + "For more information on read groups, see " + HelpConstants.articlePost(6472)); } samples.add(readGroup.getSample()); }