use of exceptions.InvalidColourException in project ASCIIGenome by dariober.
the class InteractiveInput method setConfigOpt.
private void setConfigOpt(List<String> cmdTokens) throws IOException, InvalidConfigException, InvalidCommandLineException, InvalidColourException {
List<String> args = new ArrayList<String>(cmdTokens);
args.remove(0);
if (args.size() == 0) {
throw new InvalidCommandLineException();
}
if (args.size() == 1) {
ConfigKey key = ConfigKey.getConfigKeyFromShort(args.get(0));
if (ConfigKey.booleanKeys().contains(key)) {
// If configkey is a type boolean, just flip the boolean
key = ConfigKey.valueOf(key.toString());
boolean value = !Utils.asBoolean(Config.get(key));
Config.set(key, String.valueOf(value));
} else {
// configKey is expected to be the name of a configuration file
new Config(args.get(0));
}
} else {
ConfigKey key = ConfigKey.getConfigKeyFromShort(args.get(0));
String value = args.get(1);
try {
Config.set(key, value);
} catch (Exception e) {
throw new InvalidConfigException();
}
}
}
use of exceptions.InvalidColourException in project ASCIIGenome by dariober.
the class Utils method hasTabixIndex.
// public static LinkedHashMap<String, Integer> xterm256ColorCodes(){
// // See http://misc.flogisoft.com/bash/tip_colors_and_formatting
// // From http://jonasjacek.github.io/colors/
// LinkedHashMap<String, Integer> colourCodes= new LinkedHashMap<String, Integer>();
// colourCodes.put("default", 39);
// colourCodes.put("black", 30);
// colourCodes.put("red", 31);
// colourCodes.put("green", 32);
// colourCodes.put("yellow", 33);
// colourCodes.put("blue", 34);
// colourCodes.put("magenta", 35);
// colourCodes.put("cyan", 36);
// colourCodes.put("light_grey", 37);
// colourCodes.put("grey", 90);
// colourCodes.put("light_red", 91);
// colourCodes.put("light_green", 92);
// colourCodes.put("light_yellow", 93);
// colourCodes.put("light_blue", 94);
// colourCodes.put("light_magenta", 95);
// colourCodes.put("light_cyan", 96);
// colourCodes.put("white", 97);
// // To be continued
// return colourCodes;
// }
// public static Color ansiColourToGraphicsColor(int ansiColor) throws InvalidColourException{
//
// if(!xterm256ColorCodes().entrySet().contains(ansiColor)){
// throw new InvalidColourException();
// }
// if(ansiColor == 30){ return Color.BLACK; }
// if(ansiColor == 31 || ansiColor == 91){ return Color.RED; }
// if(ansiColor == 32 || ansiColor == 92){ return Color.GREEN; }
// if(ansiColor == 33 || ansiColor == 93){ return Color.YELLOW; }
// if(ansiColor == 34 || ansiColor == 94){ return Color.BLUE; }
// if(ansiColor == 35 || ansiColor == 95){ return Color.MAGENTA; }
// if(ansiColor == 36 || ansiColor == 96){ return Color.CYAN; }
// if(ansiColor == 37){ return Color.LIGHT_GRAY; }
// if(ansiColor == 90){ return Color.DARK_GRAY; }
// if(ansiColor == 97){ return Color.WHITE; }
// return Color.BLACK;
// }
/**
* Return true if fileName has a valid tabix index.
* @throws IOException
*/
public static boolean hasTabixIndex(String fileName) throws IOException {
if ((new UrlValidator()).isValid(fileName) && fileName.startsWith("ftp")) {
// Because of issue #51
return false;
}
try {
TabixReader tabixReader = new TabixReader(fileName);
tabixReader.readLine();
tabixReader.close();
return true;
} catch (Exception e) {
return false;
}
}
Aggregations