Example usage for org.apache.commons.io FilenameUtils removeExtension

List of usage examples for org.apache.commons.io FilenameUtils removeExtension

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils removeExtension.

Prototype

public static String removeExtension(String filename) 

Source Link

Document

Removes the extension from a filename.

Usage

From source file:com.uwsoft.editor.proxy.ResolutionManager.java

public void createResizedAnimations(ResolutionEntryVO resolution) {
    ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
    String currProjectPath = projectManager.getCurrentProjectPath();

    // Unpack spine orig
    File spineSourceDir = new File(currProjectPath + File.separator + "assets/orig/spine-animations");
    if (spineSourceDir.exists()) {
        for (File entry : spineSourceDir.listFiles()) {
            if (entry.isDirectory()) {
                String animName = FilenameUtils.removeExtension(entry.getName());
                createResizedSpineAnimation(animName, resolution);
            }/*from   w w  w  . j  ava 2  s  .c om*/
        }
    }

    //Unpack sprite orig
    File spriteSourceDir = new File(currProjectPath + File.separator + "assets/orig/sprite-animations");
    if (spriteSourceDir.exists()) {
        for (File entry : spriteSourceDir.listFiles()) {
            if (entry.isDirectory()) {
                String animName = FilenameUtils.removeExtension(entry.getName());
                createResizedSpriteAnimation(animName, resolution);
            }
        }
    }
}

From source file:ffx.algorithms.DiscountPh.java

/**
 * Construct a "Discrete-Continuous" Monte-Carlo titration engine.
 * For traditional discrete titration, use Protonate.
 * For traditional continuous titration, run mdesv for populations.
 * //from  www  .ja v a  2s  . co m
 * @param mola the molecular assembly
 * @param mcStepFrequency number of MD steps between switch attempts
 * @param pH the simulation pH
 * @param thermostat the MD thermostat
 */
// java.lang.Double, java.lang.Integer, java.lang.Integer, java.lang.Boolean, java.lang.String, java.lang.Integer, null)
DiscountPh(MolecularAssembly mola, ExtendedSystem esvSystem, MolecularDynamics molDyn, double timeStep,
        double printInterval, double saveInterval, boolean initVelocities, String fileType,
        double writeRestartInterval, File dyn) {
    this.mola = mola;
    this.esvSystem = esvSystem;
    this.molDyn = molDyn;
    this.dt = timeStep;
    this.printInterval = printInterval;
    this.saveInterval = saveInterval;
    this.initVelocities = initVelocities;
    this.fileType = fileType;
    this.writeRestartInterval = writeRestartInterval;
    this.dynLoader = dyn;

    this.ff = mola.getForceField();
    this.ffe = mola.getPotentialEnergy();
    this.originalFilename = FilenameUtils.removeExtension(mola.getFile().getAbsolutePath()) + "_dyn.pdb";
    SystemFilter.setVersioning(SystemFilter.Versioning.PREFIX_ABSOLUTE);
    library = RotamerLibrary.getDefaultLibrary();

    // Print system props.
    System.getProperties().keySet().stream().filter(k -> {
        String key = k.toString().toLowerCase();
        for (String prefix : keyPrefixes) {
            if (key.startsWith(prefix)) {
                return true;
            }
        }
        return false;
    }).forEach(key -> SB.logf(" #%s=%s", key.toString(), System.getProperty(key.toString())));
    SB.printIfPresent(" Advanced option flags:");

    if (testInterpolation) {
        testInterpolation();
        System.exit(0);
    }

    // Set the rotamer library in case we do rotamer MC moves.
    library.setLibrary(RotamerLibrary.ProteinLibrary.Richardson);
    library.setUseOrigCoordsRotamer(false);

    logf(" Running DISCOuNT-pH dynamics @ system pH %.2f\n", pH);

    ffe.reInit();
}

From source file:com.googlecode.fascinator.portal.services.impl.CachingDynamicPageServiceImpl.java

/**
 * Renders the Velocity template with the specified form data.
 * // w  w  w . j  av a2 s .  c  o  m
 * @param portalId the portal to get the template from
 * @param pageName the page template to render
 * @param out render results will be written to this output stream
 * @param formData request form data
 * @param sessionState current session
 * @return MIME type of the response
 */
@Override
public String render(String portalId, String pageName, OutputStream out, FormData formData,
        JsonSessionState sessionState) {

    // remove extension for special cases
    boolean isAjax = pageName.endsWith(AJAX_EXT);
    boolean isScript = pageName.endsWith(SCRIPT_EXT);
    if (isAjax || isScript) {
        pageName = FilenameUtils.removeExtension(pageName);
    }

    // setup script and velocity context
    String contextPath = request.getContextPath();
    int serverPort = requestGlobals.getHTTPServletRequest().getServerPort();

    Map<String, Object> bindings = new HashMap<String, Object>();
    bindings.put("systemConfig", config);
    bindings.put("Services", scriptingServices);
    bindings.put("systemProperties", System.getProperties());
    bindings.put("request", request);
    bindings.put("httpServletRequest", requestGlobals.getHTTPServletRequest());
    bindings.put("response", response);
    bindings.put("formData", formData);
    bindings.put("sessionState", sessionState);
    bindings.put("security", security);
    bindings.put("contextPath", contextPath);
    bindings.put("scriptsPath", portalPath + "/" + portalId + "/scripts");
    bindings.put("portalDir", portalPath + "/" + portalId);
    bindings.put("portalId", portalId);
    String urlBase = this.urlBase;
    if (StringUtils.isEmpty(urlBase)) {
        urlBase = getURL(requestGlobals.getHTTPServletRequest(), config);
    } else if (config.getString(null, "portal", "urlBases", portalId) != null) {
        urlBase = config.getString(null, "portal", "urlBases", portalId);
    }
    bindings.put("urlBase", urlBase);
    if (versionString == null) {
        bindings.put("portalPath", urlBase + portalId);
    } else {
        bindings.put("portalPath", urlBase + "verNum" + versionString + "/" + portalId);
    }
    bindings.put("defaultPortal", defaultPortal);
    bindings.put("pageName", pageName);
    bindings.put("serverPort", serverPort);
    bindings.put("toolkit", toolkit);
    bindings.put("log", log);
    bindings.put("notifications", houseKeeping.getUserMessages());
    bindings.put("bindings", bindings);
    StorageDataUtil dataUtil = new StorageDataUtil();
    bindings.put("jsonUtil", dataUtil);
    // run page and template scripts
    Set<String> messages = new HashSet<String>();
    bindings.put("page", evalScript(portalId, layoutName, bindings, messages));
    bindings.put("StringUtils", StringUtils.class);
    bindings.put("StringEscapeUtils", StringEscapeUtils.class);
    bindings.put("self", evalScript(portalId, pageName, bindings, messages));

    // try to return the proper MIME type
    String mimeType = "text/html";
    Object mimeTypeAttr = request.getAttribute("Content-Type");
    if (mimeTypeAttr != null) {
        mimeType = mimeTypeAttr.toString();
    }

    // stop here if the scripts have already sent a response
    boolean committed = response.isCommitted();
    if (committed) {
        // log.debug("Response has been sent or redirected");
        return mimeType;
    }

    if (velocityService.resourceExists(portalId, pageName + ".vm") != null) {
        // set up the velocity context
        VelocityContext vc = new VelocityContext();
        for (String key : bindings.keySet()) {
            vc.put(key, bindings.get(key));
        }
        vc.put("velocityContext", vc);
        if (!messages.isEmpty()) {
            vc.put("renderMessages", messages);
        }

        try {
            // render the page content
            log.debug("Rendering page {}/{}.vm...", portalId, pageName);
            StringWriter pageContentWriter = new StringWriter();
            velocityService.renderTemplate(portalId, pageName, vc, pageContentWriter);
            if (isAjax || isScript) {
                out.write(pageContentWriter.toString().getBytes("UTF-8"));
            } else {
                vc.put("pageContent", pageContentWriter.toString());
            }
        } catch (Exception e) {
            ByteArrayOutputStream eOut = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(eOut));
            String eMsg = eOut.toString();
            log.error("Failed to render page ({})!\n=====\n{}\n=====",
                    isAjax ? "ajax" : (isScript ? "script" : "html"), eMsg);
            String errorMsg = "<pre>Page content template error: " + pageName + "\n" + eMsg + "</pre>";
            if (isAjax || isScript) {
                try {
                    out.write(errorMsg.getBytes());
                } catch (Exception e2) {
                    log.error("Failed to output error message!");
                }
            } else {
                vc.put("pageContent", errorMsg);
            }
        }

        if (!(isAjax || isScript)) {
            try {
                // render the page using the layout template
                log.debug("Rendering layout {}/{}.vm for page {}.vm...",
                        new Object[] { portalId, layoutName, pageName });
                Writer pageWriter = new OutputStreamWriter(out, "UTF-8");
                velocityService.renderTemplate(portalId, layoutName, vc, pageWriter);
                pageWriter.close();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }

    return mimeType;
}

From source file:de.teamgrit.grit.preprocess.tokenize.GeneralTokenizer.java

/**
 * On the submission level, this function gathers all relevant files and
 * returns them.//w w w  .  j a  v  a  2s  .co  m
 * 
 * @param location
 *            Where to look for files
 * @return Files matching suffixRegex in the given folder
 */
private List<Path> extractSubmissionFiles(Path location) {
    List<Path> submissionFiles = new LinkedList<>();

    m_log.info("Extracting files.");

    // Check if our location has any submissions files (as recognized by
    // their suffix. if so, note it.
    for (File currentFile : location.toFile().listFiles()) {

        // unpack archives
        if (currentFile.toString().matches(m_archiveRegex)) {
            try {
                // the number indicates to which level of a zipfile nested
                // zipfiles will be extracted
                ArchiveHandler unzipper = new ZipfileHandler(5, Paths.get(".").toFile());

                Path unzippedDir = Paths.get(FilenameUtils.removeExtension(currentFile.toString()));

                unzipper.extractZip(currentFile, unzippedDir.toFile());

                submissionFiles.add(unzippedDir);

            } catch (FileNotFoundException | ZipException e) {
                m_log.info("Error while unzipping ilias submission" + e.getMessage());
            } catch (NoProperParameterException e) {
                m_log.info("Bad parameters for zip." + e.getMessage());
            }
        } else if (currentFile.toString().matches(m_sourceSuffixRegex)) {
            m_log.info("Found: " + currentFile.toString());
            if (!submissionFiles.contains(location)) {
                submissionFiles.add(location);
            }
        } else {
            m_log.info("found invalid file: " + currentFile.toString());
        }
    }
    return submissionFiles;
}

From source file:ch.cyberduck.ui.cocoa.odb.EditorFactory.java

/**
 * Determine the human readable application name for a given bundle identifier.
 *
 * @param bundleIdentifier//from   w  w  w  .  j  a  v  a2s  .  co  m
 * @return
 */
public static String getApplicationName(String bundleIdentifier) {
    if (!applicationNameCache.containsKey(bundleIdentifier)) {
        log.debug("getApplicationName:" + bundleIdentifier);
        final String path = NSWorkspace.sharedWorkspace()
                .absolutePathForAppBundleWithIdentifier(bundleIdentifier);
        if (StringUtils.isBlank(path)) {
            log.warn("Cannot determine installation path for " + bundleIdentifier);
            applicationNameCache.put(bundleIdentifier, null);
            return null;
        }
        NSBundle app = NSBundle.bundleWithPath(path);
        if (null == app) {
            log.error("Loading bundle failed:" + path);
            applicationNameCache.put(bundleIdentifier, null);
            return null;
        }
        NSDictionary dict = app.infoDictionary();
        if (null == dict) {
            log.error("Loading application dictionary failed:" + path);
            applicationNameCache.put(bundleIdentifier, null);
            return null;
        }
        final NSObject name = dict.objectForKey("CFBundleName");
        if (null == name) {
            log.warn("No CFBundleName for " + bundleIdentifier);
            applicationNameCache.put(bundleIdentifier,
                    FilenameUtils.removeExtension(LocalFactory.createLocal(path).getDisplayName()));
        } else {
            applicationNameCache.put(bundleIdentifier, name.toString());
        }
    }
    return applicationNameCache.get(bundleIdentifier);
}

From source file:com.o2d.pkayjava.editor.proxy.ResolutionManager.java

public void createResizedAnimations(ResolutionEntryVO resolution) {
    ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME);
    String currProjectPath = projectManager.getCurrentWorkingPath() + File.separator
            + projectManager.getCurrentProjectVO().projectName;

    // Unpack spine orig
    File spineSourceDir = new File(currProjectPath + File.separator + "assets/orig/spine-animations");
    if (spineSourceDir.exists()) {
        for (File entry : spineSourceDir.listFiles()) {
            if (entry.isDirectory()) {
                String animName = FilenameUtils.removeExtension(entry.getName());
                createResizedSpineAnimation(animName, resolution);
            }/*from  w  w  w .  ja va  2  s .co  m*/
        }
    }

    //Unpack sprite orig
    File spriteSourceDir = new File(currProjectPath + File.separator + "assets/orig/sprite-animations");
    if (spriteSourceDir.exists()) {
        for (File entry : spriteSourceDir.listFiles()) {
            if (entry.isDirectory()) {
                String animName = FilenameUtils.removeExtension(entry.getName());
                createResizedSpriteAnimation(animName, resolution);
            }
        }
    }
}

From source file:net.sf.mzmine.desktop.impl.projecttree.ProjectTreeMouseHandler.java

public void actionPerformed(ActionEvent e) {

    String command = e.getActionCommand();

    // Actions for raw data files

    if (command.equals("SHOW_TIC")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        TICVisualizerModule.setupNewTICVisualizer(selectedFiles);
    }//from   ww w. j a  v a2  s  .  co m

    if (command.equals("SHOW_SPECTRUM")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        SpectraVisualizerModule module = MZmineCore.getModuleInstance(SpectraVisualizerModule.class);
        ParameterSet parameters = MZmineCore.getConfiguration()
                .getModuleParameters(SpectraVisualizerModule.class);
        parameters.getParameter(SpectraVisualizerParameters.dataFiles)
                .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
        MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
        if (exitCode == ExitCode.OK)
            module.runModule(project, parameters, new ArrayList<Task>());
    }

    if (command.equals("SHOW_IDA")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        IDAVisualizerModule.showIDAVisualizerSetupDialog(selectedFiles[0]);

    }

    if (command.equals("SHOW_2D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        TwoDVisualizerModule.show2DVisualizerSetupDialog(selectedFiles[0]);
    }

    if (command.equals("SHOW_3D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        ThreeDVisualizerModule.setupNew3DVisualizer(selectedFiles[0]);
    }

    if (command.equals("SORT_FILES")) {
        // save current selection
        TreePath savedSelection[] = tree.getSelectionPaths();
        RawDataFile selectedFiles[] = tree.getSelectedObjects(RawDataFile.class);
        OrderDataFilesModule module = MZmineCore.getModuleInstance(OrderDataFilesModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(OrderDataFilesModule.class);
        params.getParameter(OrderDataFilesParameters.dataFiles)
                .setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }

    if (command.equals("REMOVE_EXTENSION")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        for (RawDataFile file : selectedFiles) {
            file.setName(FilenameUtils.removeExtension(file.toString()));
        }
        tree.updateUI();
    }

    if (command.equals("REMOVE_FILE")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        PeakList allPeakLists[] = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
        for (RawDataFile file : selectedFiles) {
            for (PeakList peakList : allPeakLists) {
                if (peakList.hasRawDataFile(file)) {
                    String msg = "Cannot remove file " + file.getName()
                            + ", because it is present in the peak list " + peakList.getName();
                    MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), msg);
                    return;
                }
            }
            MZmineCore.getProjectManager().getCurrentProject().removeFile(file);
        }
    }

    // Actions for scans

    if (command.equals("SHOW_SCAN")) {
        Scan selectedScans[] = tree.getSelectedObjects(Scan.class);
        for (Scan scan : selectedScans) {
            SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
        }
    }

    if (command.equals("SHOW_MASSLIST")) {
        MassList selectedMassLists[] = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            SpectraVisualizerWindow window = SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(),
                    scan.getScanNumber());
            MassListDataSet dataset = new MassListDataSet(massList);
            window.addDataSet(dataset, Color.green);
        }
    }

    if (command.equals("REMOVE_MASSLIST")) {
        MassList selectedMassLists[] = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            scan.removeMassList(massList);
        }
    }

    if (command.equals("REMOVE_ALL_MASSLISTS")) {
        MassList selectedMassLists[] = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            String massListName = massList.getName();
            RawDataFile dataFiles[] = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
            for (RawDataFile dataFile : dataFiles) {
                int scanNumbers[] = dataFile.getScanNumbers();
                for (int scanNum : scanNumbers) {
                    Scan scan = dataFile.getScan(scanNum);
                    MassList ml = scan.getMassList(massListName);
                    if (ml != null)
                        scan.removeMassList(ml);
                }
            }
        }
    }

    // Actions for peak lists

    if (command.equals("SHOW_PEAKLIST_TABLES")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            PeakListTableModule.showNewPeakListVisualizerWindow(peakList);
        }
    }

    if (command.equals("SHOW_PEAKLIST_INFO")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            InfoVisualizerModule.showNewPeakListInfo(peakList);
        }
    }

    if (command.equals("SHOW_SCATTER_PLOT")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            ScatterPlotVisualizerModule.showNewScatterPlotWindow(peakList);
        }
    }

    if (command.equals("SORT_PEAKLISTS")) {
        // save current selection
        TreePath savedSelection[] = tree.getSelectionPaths();
        PeakList selectedPeakLists[] = tree.getSelectedObjects(PeakList.class);
        OrderPeakListsModule module = MZmineCore.getModuleInstance(OrderPeakListsModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(OrderPeakListsModule.class);
        params.getParameter(OrderPeakListsParameters.peakLists)
                .setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, selectedPeakLists);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }

    if (command.equals("REMOVE_PEAKLIST")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists)
            MZmineCore.getProjectManager().getCurrentProject().removePeakList(peakList);
    }

    // Actions for peak list rows

    if (command.equals("SHOW_PEAK_SUMMARY")) {
        PeakListRow[] selectedRows = tree.getSelectedObjects(PeakListRow.class);
        for (PeakListRow row : selectedRows) {
            PeakSummaryVisualizerModule.showNewPeakSummaryWindow(row);
        }
    }

}

From source file:de.fhg.iais.asc.xslt.binaries.DownloadAndScaleBinary.java

public List<Object> createAllVariants(List<PreviewImageType> previewTypes) {
    List<Object> result = new ArrayList<Object>();

    if (this.context.isTypeAllowed("orig")) {
        makeOriginalLocallyAvailable(DOWNLOAD_PERMANENT_ONLY);
    }//from ww w .  ja v  a  2s . co m

    if ((this.mimeType == null) || (this.mimeType.equals(""))) {
        this.mimeType = detectMimetype();

        if (this.mimeType.equals("video/quicktime")) {
            this.mimeType = "video/mp4";
        }
    }

    if (this.mimeType.startsWith("audio/") || this.mimeType.startsWith("video/")
            || this.mimeType.equals("application/pdf")) { // is audio, video or pdf
        if (this.mimeType.equals("video/vimeo")) { // if external video
            result.add(this.typeSubPath);
        } else if (this.locallyAvailableOriginal == this.permanentOriginal) {
            String filepath = "full" + "/" + this.typeSubPath;
            result.add(filepath);
            File binary = new File(this.context.getBinaryRoot() + "/" + filepath);
            try {
                FileUtils.copyFile(this.locallyAvailableOriginal, binary);

            } catch (IOException e) {
                LOG.error("Can't create directory 'full': " + e);

            }
        } else if (this.downloadableURI != null) {
            result.add(this.downloadableURI);
        }
    } else if (!this.mimeType.startsWith("image/")) {
        if (this.locallyAvailableOriginal != null) {
            this.locallyAvailableOriginal.delete();
        }
    }

    if ((this.mimeType.startsWith("image/") || (this.mimeType.equals("application/pdf")))) { // is image or pdf
        if (this.context.isAnyScaleAllowed()) {
            for (PreviewImageType previewType : previewTypes) {
                if (isPreviewAllowed(previewType)) {
                    final String previewTypeName = previewType.getType();
                    String scaled = previewTypeName + "/" + FilenameUtils.removeExtension(this.typeSubPath)
                            + ".jpg";
                    if (executeScale(previewType, scaled, this.mimeType)) {
                        result.add(scaled);
                    } else { // delete file if scaling could not be executed (e.g. damaged image)
                        if (this.locallyAvailableOriginal != null) {
                            this.locallyAvailableOriginal.delete();
                        }
                    }
                }
            }
        }
    }

    return result;
}

From source file:brooklyn.entity.dns.geoscaling.GeoscalingWebClient.java

public void createPrimaryDomain(String name) {
    try {/*  w  w w. j a va  2s . c  o  m*/
        name = name.toLowerCase();
        String url = MessageFormat.format("https://{0}/{1}?module=domains", HOST, PATH);

        HttpPost request = new HttpPost(url);
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("MAX_FILE_SIZE", "65536"));
        nameValuePairs.add(new BasicNameValuePair("domain", FilenameUtils.removeExtension(name)));
        nameValuePairs.add(new BasicNameValuePair("tld", FilenameUtils.getExtension(name)));
        request.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        sendRequest(request, true);

    } catch (Exception e) {
        throw new RuntimeException("Failed to create GeoScaling smart subdomain: " + e, e);
    }

    primaryDomains = fetchPrimaryDomains();
}

From source file:ffx.xray.Rescore.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 va 2s  .c o  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, new ParallelTeam(),
                    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;
}