Search in sources :

Example 1 with InvalidColourException

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();
        }
    }
}
Also used : ConfigKey(coloring.ConfigKey) Config(coloring.Config) ArrayList(java.util.ArrayList) InvalidCommandLineException(exceptions.InvalidCommandLineException) InvalidConfigException(exceptions.InvalidConfigException) InvalidCommandLineException(exceptions.InvalidCommandLineException) InvalidColourException(exceptions.InvalidColourException) InvalidRecordException(exceptions.InvalidRecordException) SQLException(java.sql.SQLException) ArgumentParserException(net.sourceforge.argparse4j.inf.ArgumentParserException) InvalidConfigException(exceptions.InvalidConfigException) PatternSyntaxException(java.util.regex.PatternSyntaxException) IOException(java.io.IOException) InvalidGenomicCoordsException(exceptions.InvalidGenomicCoordsException)

Example 2 with InvalidColourException

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;
    }
}
Also used : TabixReader(htsjdk.tribble.readers.TabixReader) UrlValidator(org.apache.commons.validator.routines.UrlValidator) InvalidCommandLineException(exceptions.InvalidCommandLineException) InvalidRecordException(exceptions.InvalidRecordException) InvalidColourException(exceptions.InvalidColourException) SQLException(java.sql.SQLException) IOException(java.io.IOException) UnindexableFastaFileException(faidx.UnindexableFastaFileException) FileNotFoundException(java.io.FileNotFoundException) InvalidGenomicCoordsException(exceptions.InvalidGenomicCoordsException) MalformedURLException(java.net.MalformedURLException)

Aggregations

InvalidColourException (exceptions.InvalidColourException)2 InvalidCommandLineException (exceptions.InvalidCommandLineException)2 InvalidGenomicCoordsException (exceptions.InvalidGenomicCoordsException)2 InvalidRecordException (exceptions.InvalidRecordException)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 Config (coloring.Config)1 ConfigKey (coloring.ConfigKey)1 InvalidConfigException (exceptions.InvalidConfigException)1 UnindexableFastaFileException (faidx.UnindexableFastaFileException)1 TabixReader (htsjdk.tribble.readers.TabixReader)1 FileNotFoundException (java.io.FileNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 ArgumentParserException (net.sourceforge.argparse4j.inf.ArgumentParserException)1 UrlValidator (org.apache.commons.validator.routines.UrlValidator)1