コード例 #1
0
 /**
  * @param inputFile input file
  * @return a new File with prefix ".sorted" added before the extension
  */
 public static File generateOutputFile(File inputFile) {
   String extension = Utils.getExtension(inputFile);
   String nameWithoutExtension = Utils.getFileNameWithoutExtension(inputFile);
   String newFileName = nameWithoutExtension + ".sorted." + extension;
   File parentDirectory = inputFile.getParentFile();
   return new File(parentDirectory, newFileName);
 }
コード例 #2
0
 /**
  * @param inputFile
  * @return a string comparator adapted that compares the lines of the input file
  * @throws InvalidParameterException
  */
 private static Comparator<String> generateComparator(File inputFile)
     throws InvalidParameterException {
   String fileExtension = Utils.getExtension(inputFile);
   if (fileExtension == null) {
     throw new InvalidParameterException(
         "Cannot sort the specified file: "
             + inputFile.getName()
             + "\n"
             + "Files without extension are not recognized by the sorting function");
   } else if (fileExtension.equalsIgnoreCase("gff")) {
     return new GenomicFileLineComparator(0, 3, 4);
   } else if (fileExtension.equalsIgnoreCase("gr")) {
     return new GenomicFileLineComparator(0, 1, 2);
   } else if (fileExtension.equalsIgnoreCase("bed")) {
     return new GenomicFileLineComparator(0, 1, 2);
   } else if (fileExtension.equalsIgnoreCase("bgr")) {
     return new GenomicFileLineComparator(0, 1, 2);
   } else if (fileExtension.equalsIgnoreCase("pair")) {
     return new GenomicFileLineComparator(0, 4, 4);
   } else if (fileExtension.equalsIgnoreCase("psl")) {
     return new GenomicFileLineComparator(13, 15, 16);
   } else if (fileExtension.equalsIgnoreCase("sam")) {
     return new GenomicFileLineComparator(0, 3, 3);
   } else {
     throw new InvalidParameterException(
         "Cannot sort the specified file: "
             + inputFile.getName()
             + "\n"
             + "Files with "
             + fileExtension
             + " extension are not recognized by the sorting function");
   }
 }