X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FGeneticCodes.java;h=df1dd8255e97fe5fe18404efba3fb23f85127c4e;hb=9c127c47a7bf73c3e538815635f525fe59f7faba;hp=d07253ee429db9975fc012afad7d975bb89830a7;hpb=af65be61ff37a024b694150efed2c6c9b81382ef;p=jalview.git diff --git a/src/jalview/analysis/GeneticCodes.java b/src/jalview/analysis/GeneticCodes.java index d07253e..df1dd82 100644 --- a/src/jalview/analysis/GeneticCodes.java +++ b/src/jalview/analysis/GeneticCodes.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.analysis; import jalview.bin.Cache; @@ -65,7 +85,7 @@ public final class GeneticCodes loadAmbiguityCodes(AMBIGUITY_CODES_FILE); loadCodes(RESOURCE_FILE); } - }; + } /** * Returns the singleton instance of this class @@ -117,6 +137,11 @@ public final class GeneticCodes try { InputStream is = getClass().getResourceAsStream(fileName); + if (is == null) + { + System.err.println("Resource file not found: " + fileName); + return; + } BufferedReader dataIn = new BufferedReader(new InputStreamReader(is)); /* @@ -136,9 +161,15 @@ public final class GeneticCodes } catch (IOException | NullPointerException e) { Cache.log.error( - "Error reading genetic codes data file: " + "Error reading genetic codes data file " + fileName + ": " + e.getMessage()); } + if (codeTables.isEmpty()) + { + System.err.println( + "No genetic code tables loaded, check format of file " + + fileName); + } } /** @@ -157,6 +188,11 @@ public final class GeneticCodes try { InputStream is = getClass().getResourceAsStream(fileName); + if (is == null) + { + System.err.println("Resource file not found: " + fileName); + return; + } BufferedReader dataIn = new BufferedReader(new InputStreamReader(is)); String line = ""; while (line != null) @@ -165,8 +201,16 @@ public final class GeneticCodes if (line != null && !"DNA".equals(line.toUpperCase())) { String[] tokens = line.split("\\t"); + if (tokens.length == 2) + { ambiguityCodes.put(tokens[0].toUpperCase(), tokens[1].toUpperCase()); + } + else + { + System.err.println( + "Unexpected data in " + fileName + ": " + line); + } } } } catch (IOException e)