List of usage examples for org.apache.commons.io FilenameUtils removeExtension
public static String removeExtension(String filename)
From source file:ffx.xray.RescoreAndCluster.java
private File rescoreSingle(File modelFile, RescoreStrategy rscType, DoubleIndexPair[] energies, int i) { Path filepath = generatePath(modelFile); if (filepath == null) { logger.warning(String.format(" Could not generate path to file %s", modelFile.toPath())); return null; }/*from w ww . j a v a 2 s .co m*/ String filename = pwdPath.relativize(filepath).toString(); File retFile = modelFile; try { MolecularAssembly[] openedAssemblies = utils.open(filename); MolecularAssembly assembly = openedAssemblies[0]; switch (rscType) { case NO_RESCORE: logger.warning(" Rescore is being called with rscType = NO_RESCORE"); break; case ENERGY_EVAL: break; case MINIMIZE: logger.info(String.format("\n Running minimize on %s", filename)); logger.info(String.format(" RMS gradient convergence criteria: %f", eps)); utils.energy(assembly); utils.minimize(assembly, eps); String ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix).concat(ext); retFile = new File(filename); if (ext.toUpperCase().contains("XYZ")) { utils.saveAsXYZ(assembly, retFile); } else { utils.saveAsPDB(assembly, retFile); } break; case XRAY_MIN: logger.info(String.format("\n Running x-ray minimize on %s", filename)); DiffractionFile diffractionFile = null; if (diffractionFiles.isEmpty()) { diffractionFile = new DiffractionFile(assembly, 1.0, false); diffractionFiles.add(diffractionFile); } CompositeConfiguration properties = Keyword.loadProperties(modelFile); DiffractionData diffractionData = new DiffractionData(assembly, properties, SolventModel.POLYNOMIAL, diffractionFiles.toArray(new DiffractionFile[diffractionFiles.size()])); diffractionData.scaleBulkFit(); diffractionData.printStats(); utils.energy(assembly); RefinementMinimize refinementMinimize = new RefinementMinimize(diffractionData, refinementMode); if (eps < 0.0) { eps = refinementMinimize.getEps(); } logger.info(String.format("\n RMS gradient convergence criteria: %8.5f max number of iterations %d", eps, maxiter)); refinementMinimize.minimize(eps, maxiter); diffractionData.scaleBulkFit(); diffractionData.printStats(); ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix); diffractionData.writeData(filename + ".mtz"); filename = filename.concat(ext); diffractionData.writeModel(filename); retFile = new File(filename); if (diffractionFile != null) { try { diffractionFiles.remove(diffractionFile); } catch (UnsupportedOperationException ex) { // This should never occur, because diffractionFiles should be of a List type supporting remove(object). diffractionFiles = new ArrayList<>(); } } break; case RS_MIN: logger.info(String.format("\n Running real-space minimize on %s", filename)); RealSpaceFile realspaceFile = null; if (mapFiles.isEmpty()) { realspaceFile = new RealSpaceFile(assembly); mapFiles.add(realspaceFile); } properties = Keyword.loadProperties(modelFile); RealSpaceData realspaceData = new RealSpaceData(assembly, properties, mapFiles.toArray(new RealSpaceFile[mapFiles.size()])); utils.energy(assembly); refinementMinimize = new RefinementMinimize(realspaceData, refinementMode); if (eps < 0.0) { eps = 1.0; } logger.info(String.format("\n RMS gradient convergence criteria: %8.5f max number of iterations %d", eps, maxiter)); refinementMinimize.minimize(eps, maxiter); ext = FilenameUtils.getExtension(filename); ext = ".".concat(ext); if (resultDir != null) { filename = FilenameUtils.getBaseName(filename); filename = FilenameUtils.concat(resultPath.toString(), filename); } else { filename = FilenameUtils.removeExtension(filename); } filename = filename.concat(fileSuffix).concat(ext); retFile = new File(filename); if (ext.toUpperCase().contains("XYZ")) { utils.saveAsXYZ(assembly, retFile); } else { utils.saveAsPDB(assembly, retFile); } if (realspaceFile != null) { try { mapFiles.remove(realspaceFile); } catch (UnsupportedOperationException ex) { // This should never occur, because diffractionFiles should be of a List type supporting remove(object). mapFiles = new ArrayList<>(); } } break; default: logger.severe(" No valid rescore type: FFX will not continue."); } double e = utils.returnEnergy(assembly); energies[i] = new DoubleIndexPair(i, e); utils.closeAll(openedAssemblies); } catch (Exception ex) { logger.warning(String.format(" Exception rescoring on file %s", filename)); logger.info(ex.toString()); } return retFile; }
From source file:com.uwsoft.editor.controlles.ResolutionManager.java
public void resizeSpineAnimationForAllResolutions(File atlasFile, ProjectInfoVO currentProjectInfoVO) { String fileNameWithOutExt = FilenameUtils.removeExtension(atlasFile.getName()); String tmpDir = dataManager.getCurrentWorkingPath() + File.separator + dataManager.getCurrentProjectVO().projectName + "/assets/orig/spine-animations" + File.separator + fileNameWithOutExt + File.separator + "tmp"; File sourceFolder = new File(tmpDir); unpackAtlasIntoTmpFolder(atlasFile, tmpDir); try {/* w ww . j a va2 s . co m*/ for (ResolutionEntryVO resolutionEntryVO : currentProjectInfoVO.resolutions) { FileUtils.forceMkdir(new File(dataManager.getCurrentWorkingPath() + "/" + dataManager.getCurrentProjectVO().projectName + File.separator + "assets" + File.separator + resolutionEntryVO.name + File.separator + "spine-animations")); String targetPath = dataManager.getCurrentWorkingPath() + "/" + dataManager.getCurrentProjectVO().projectName + File.separator + "assets" + File.separator + resolutionEntryVO.name + File.separator + "spine-animations" + File.separator + fileNameWithOutExt; FileUtils.forceMkdir(new File(targetPath)); File targetFolder = new File(targetPath); resizeImagesTmpDirToResolution(atlasFile.getName(), sourceFolder, resolutionEntryVO, targetFolder); } FileUtils.deleteDirectory(sourceFolder); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.liferay.sync.engine.SyncSystemTest.java
protected Path getDependencyFilePath(Path testFilePath, String dependency) throws Exception { String filePathName = null;/*from w w w. j ava 2s . c o m*/ if (dependency.contains("common")) { filePathName = FileUtil.getFilePathName("tests", "dependencies", dependency); } else { Path testFileNameFilePath = testFilePath.getFileName(); String testFileName = testFileNameFilePath.toString(); filePathName = FileUtil.getFilePathName("tests", "dependencies", FilenameUtils.removeExtension(testFileName), dependency); } return getResourceFilePath(filePathName); }
From source file:MyFormApp.java
private void jList2AncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_jList2AncestorAdded // TODO add your handling code here: // ? LIST /*w w w . j a va2 s . c o m*/ for (File file : fileList) { // data[i] = (file.getName()); System.out.println(data[i]); String imagename = FilenameUtils.removeExtension(data[i]); int a = i + 1; model.addElement(new Book(data[i], "" + a, imagename, PATH)); // i = i + 1; } jList2.setModel(model); jList2.setCellRenderer(new BookRenderer()); }
From source file:com.uwsoft.editor.proxy.ResolutionManager.java
public void resizeSpineAnimationForAllResolutions(File atlasFile, ProjectInfoVO currentProjectInfoVO) { String fileNameWithOutExt = FilenameUtils.removeExtension(atlasFile.getName()); ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME); String tmpDir = projectManager.getCurrentProjectPath() + "/assets/orig/spine-animations" + File.separator + fileNameWithOutExt + File.separator + "tmp"; File sourceFolder = new File(tmpDir); unpackAtlasIntoTmpFolder(atlasFile, tmpDir); try {/*from w w w .j av a 2 s . co m*/ for (ResolutionEntryVO resolutionEntryVO : currentProjectInfoVO.resolutions) { FileUtils.forceMkdir(new File(projectManager.getCurrentProjectPath() + File.separator + "assets" + File.separator + resolutionEntryVO.name + File.separator + "spine-animations")); String targetPath = projectManager.getCurrentProjectPath() + File.separator + "assets" + File.separator + resolutionEntryVO.name + File.separator + "spine-animations" + File.separator + fileNameWithOutExt; FileUtils.forceMkdir(new File(targetPath)); File targetFolder = new File(targetPath); resizeImagesTmpDirToResolution(atlasFile.getName(), sourceFolder, resolutionEntryVO, targetFolder); } FileUtils.deleteDirectory(sourceFolder); } catch (IOException e) { e.printStackTrace(); } }
From source file:ca.on.oicr.pde.workflows.GATK3WorkflowTest.java
private void validateWorkflow(AbstractWorkflowDataModel w) { //check for null string for (AbstractJob j : w.getWorkflow().getJobs()) { String c = Joiner.on(" ").useForNull("null").join(j.getCommand().getArguments()); //check for null string Assert.assertFalse(c.contains("null"), "Warning: command contains \"null\":\n" + c + "\n"); // check for missing spaces Assert.assertFalse(c.matches("(.*)[^ ]--(.*)")); }//from ww w .j a v a2 s .c o m //verify bai is located in the correct provision directory Map<String, String> bamFileDirectories = new HashMap<>(); for (SqwFile f : w.getFiles().values()) { if (FilenameUtils.isExtension(f.getProvisionedPath(), "bam")) { bamFileDirectories.put(FilenameUtils.removeExtension(f.getSourcePath()), FilenameUtils.getPath(f.getProvisionedPath())); } } for (SqwFile f : w.getFiles().values()) { //FIXME: bai.getProvisionedPath != bai.getOutputPath ... // at least with seqware 1.1.0, setting output path changes where the output file will be stored, // but the commonly used get provisioned path will return the incorrect path to the file if (FilenameUtils.isExtension(f.getProvisionedPath(), "bai")) { //check bai is in the same provision directory its corresponding bam is in Assert.assertEquals(FilenameUtils.getPath(f.getOutputPath()), bamFileDirectories.get(FilenameUtils.removeExtension(f.getSourcePath()))); } } //check number of parent nodes Set<VariantCaller> vc = new HashSet<>(); for (String s : StringUtils.split(w.getConfigs().get("variant_caller"), ",")) { vc.add(VariantCaller.valueOf(StringUtils.upperCase(s))); } int parallelism = Math.max(1, StringUtils.split(w.getConfigs().get("chr_sizes"), ",").length); int expectedParentNodeCount = parallelism * (vc.contains(HAPLOTYPE_CALLER) ? 1 : 0) + parallelism * (vc.contains(UNIFIED_GENOTYPER) ? 2 : 0); //ug indels and ug snvs int actualParentNodeCount = 0; for (AbstractJob j : w.getWorkflow().getJobs()) { if (j.getParents().isEmpty()) { actualParentNodeCount++; } } Assert.assertEquals(actualParentNodeCount, expectedParentNodeCount); //view output files for (AbstractJob j : w.getWorkflow().getJobs()) { for (SqwFile f : j.getFiles()) { if (f.isOutput()) { System.out.println(f.getProvisionedPath()); } } } }
From source file:com.photon.phresco.framework.impl.ApplicationManagerImpl.java
private void deleteBuildArchive(String rootModulePath, List<BuildInfo> selectedInfos, String subModuleName) throws PhrescoException { S_LOGGER.debug(/*from w w w . ja v a2 s .c o m*/ "Entering Method AppliacationmanagerImpl.deleteBuildArchive(ProjectInfo project, List<BuildInfo> selectedInfos)"); File file = null; try { String delFilename = null; for (BuildInfo selectedInfo : selectedInfos) { //Delete zip file delFilename = selectedInfo.getBuildName(); file = new File(getBuildInfoHome(rootModulePath, subModuleName) + delFilename); FilenameUtils.removeExtension(file.getName()); File temp = new File(getBuildInfoHome(rootModulePath, subModuleName) + file.getName().substring(0, file.getName().length() - 4)); file.delete(); if (temp.exists()) { FileUtil.delete(temp); } } } catch (Exception e) { throw new PhrescoException(e); } }
From source file:Import.pnl_import_vcf.java
private void btn_importActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_importActionPerformed // TODO add your handling code here: String[] singleColumns = singleColumns(); String[] selectedFamilies = selectedFamilies(); CheckBoxList checkList = new CheckBoxList(); DefaultListModel model = new DefaultListModel(); for (String a : singleColumns) { model.addElement(a);/*from w ww .ja v a 2s. c o m*/ } checkList.setModel(model); String filePath = filePathField.getText(); if (rbt_existing_tbl.isSelected()) { try { String[] selectedTableFamilies = tableFamilies(); JTable tableMap = new JTable(); DefaultTableModel tableMapModel = (DefaultTableModel) tableMap.getModel(); setMapTable(tableMap, tableMapModel, selectedFamilies, selectedTableFamilies); int map = JOptionPane.showConfirmDialog(null, tableMap, "Please map to column", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (map == 2) { return; } Object[] o = getMapPair(tableMapModel); String selectTableName = tbl_hbase_tables.getValueAt(tbl_hbase_tables.getSelectedRow(), 0) .toString(); String[] mappedFamilies = (String[]) o[1]; String[] mappedTableFamilies = (String[]) o[0]; String[] keys = getKey(selectTableName); importToTable.importDataJob importData = new importDataJob(); importData.importData(filePath, selectTableName, mappedTableFamilies, mappedFamilies, keys); } catch (Exception ex) { Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex); } } else { try { int key = JOptionPane.showConfirmDialog(null, checkList, "Please choose Key", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null); if (key == 2) { return; } Object[] selectedKey = checkList.getCheckBoxListSelectedValues(); File f = new File(filePath); String fname = f.getName(); String tableName = FilenameUtils.removeExtension(fname); writeKey(selectedKey, tableName); writeType(tableName); createColumnsTxt(tableName); ArrayList<String> list = new ArrayList<>(); for (Object o : selectedKey) { list.add(o.toString()); } String[] keys = list.toArray(new String[list.size()]); importToNewTable.createDataJob importData = new createDataJob(); importData.importData(filePath, selectedFamilies, keys); } catch (Exception ex) { Logger.getLogger(pnl_import_vcf.class.getName()).log(Level.SEVERE, null, ex); } } filePathField.setText(null); DefaultDualListModel dualModel = new DefaultDualListModel(); list_dual_hbase_column_family.setModel(dualModel); pnl_import_vcf.showHBaseTables runabletask = new pnl_import_vcf.showHBaseTables(); new Thread(runabletask).start(); }
From source file:com.o2d.pkayjava.editor.proxy.ResolutionManager.java
public void resizeSpineAnimationForAllResolutions(File atlasFile, ProjectInfoVO currentProjectInfoVO) { String fileNameWithOutExt = FilenameUtils.removeExtension(atlasFile.getName()); ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME); String tmpDir = projectManager.getCurrentWorkingPath() + File.separator + projectManager.getCurrentProjectVO().projectName + "/assets/orig/spine-animations" + File.separator + fileNameWithOutExt + File.separator + "tmp"; File sourceFolder = new File(tmpDir); unpackAtlasIntoTmpFolder(atlasFile, tmpDir); try {//ww w.j a v a2s. c o m for (ResolutionEntryVO resolutionEntryVO : currentProjectInfoVO.resolutions) { FileUtils.forceMkdir(new File(projectManager.getCurrentWorkingPath() + "/" + projectManager.getCurrentProjectVO().projectName + File.separator + "assets" + File.separator + resolutionEntryVO.name + File.separator + "spine-animations")); String targetPath = projectManager.getCurrentWorkingPath() + "/" + projectManager.getCurrentProjectVO().projectName + File.separator + "assets" + File.separator + resolutionEntryVO.name + File.separator + "spine-animations" + File.separator + fileNameWithOutExt; FileUtils.forceMkdir(new File(targetPath)); File targetFolder = new File(targetPath); resizeImagesTmpDirToResolution(atlasFile.getName(), sourceFolder, resolutionEntryVO, targetFolder); } FileUtils.deleteDirectory(sourceFolder); } catch (IOException e) { e.printStackTrace(); } }
From source file:edu.cornell.med.icb.goby.methylation.MethylSimilarityScan.java
private MethylationData load(String inputFilename) throws IOException { System.out.println("Loading.."); final String cacheFilename = FilenameUtils.removeExtension(inputFilename) + ".cache"; File cacheFile = new File(cacheFilename); if (cacheFile.canRead()) { try {/*from w ww .ja va 2 s .c om*/ System.out.println("Trying to load cache " + cacheFilename); System.out.flush(); return (MethylationData) BinIO.loadObject(cacheFilename); } catch (ClassNotFoundException e) { System.err.println("Cannot load cache. Loading text file instead."); // continue loading as usual. } } MethylationData data = new MethylationData(); TSVReader reader = new TSVReader(new FileReader(inputFilename), '\t'); reader.setCommentPrefix("chromosome"); int count = 0; while (reader.hasNext()) { if (reader.isCommentLine()) { reader.skip(); } else { reader.next(); String chr = reader.getString(); int position = reader.getInt(); char strand = reader.getString().charAt(0); // ignore type of site. reader.getString(); int methylatedReadCount = reader.getInt(); int totalReadCount = reader.getInt(); // add element at index 'position' data.append(chr, strand, position, methylatedReadCount, totalReadCount); count++; if (count % 100000 == 1) { System.out.print("."); } } } System.out.println("done"); System.out.println("Sorting.."); // sort the sites by position: Collections.sort(data.sites, new Comparator<MethylationSite>() { public int compare(MethylationSite site1, MethylationSite site2) { if (site1.chromosome != site2.chromosome) return site1.chromosome - site2.chromosome; else return site1.position - site2.position; } }); System.out.println("Saving cache.."); System.out.flush(); BinIO.storeObject(data, cacheFilename); return data; }