List of usage examples for org.apache.commons.io FilenameUtils getFullPath
public static String getFullPath(String filename)
From source file:MSUmpire.LCMSPeakStructure.LCMSPeakDIAMS2.java
private void PrepareMGF_UnfragmentIon() throws IOException { String mgffile4 = FilenameUtils.getFullPath(ParentmzXMLName) + GetQ3Name() + ".mgf.temp"; // FileWriter mgfWriter4 = new FileWriter(mgffile4, true); final BufferedWriter mgfWriter4 = DIAPack.get_file(DIAPack.OutputFile.Mgf_Q3, mgffile4); // FileWriter mapwriter3 = new FileWriter(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + ".ScanClusterMapping_Q3", true); final BufferedWriter mapwriter3 = DIAPack.get_file(DIAPack.OutputFile.ScanClusterMapping_Q3, FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + ".ScanClusterMapping_Q3"); ArrayList<PseudoMSMSProcessing> ScanList = new ArrayList<>(); ExecutorService executorPool = Executors.newFixedThreadPool(NoCPUs); for (PeakCluster ms2cluster : PeakClusters) { ArrayList<PrecursorFragmentPairEdge> frags = UnFragIonClu2Cur.get(ms2cluster.Index); if (frags != null && DIA_MZ_Range.getX() <= ms2cluster.TargetMz() && DIA_MZ_Range.getY() >= ms2cluster.TargetMz()) { // if (DIA_MZ_Range.getX() <= ms2cluster.TargetMz() && DIA_MZ_Range.getY() >= ms2cluster.TargetMz() && UnFragIonClu2Cur.containsKey(ms2cluster.Index)) { // ArrayList<PrecursorFragmentPairEdge> frags = UnFragIonClu2Cur.get(ms2cluster.Index); ms2cluster.GroupedFragmentPeaks.addAll(frags); PseudoMSMSProcessing mSMSProcessing = new PseudoMSMSProcessing(ms2cluster, parameter); executorPool.execute(mSMSProcessing); ScanList.add(mSMSProcessing); }/* ww w.j av a2 s . c o m*/ } executorPool.shutdown(); try { executorPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { Logger.getRootLogger().info("interrupted.."); } for (PseudoMSMSProcessing mSMSProcessing : ScanList) { if (MatchedFragmentMap.size() > 0) { mSMSProcessing.RemoveMatchedFrag(MatchedFragmentMap); } XYPointCollection Scan = mSMSProcessing.GetScan(); if (Scan != null && Scan.PointCount() > parameter.MinFrag) { parentDIA.Q3Scan++; // StringBuilder mgfString = new StringBuilder(); // mgfString.append("BEGIN IONS\n"); // mgfString.append("PEPMASS=" + mSMSProcessing.Precursorcluster.TargetMz() + "\n"); // mgfString.append("CHARGE=" + mSMSProcessing.Precursorcluster.Charge + "+\n"); // mgfString.append("RTINSECONDS=" + mSMSProcessing.Precursorcluster.PeakHeightRT[0] * 60f + "\n"); // mgfString.append("TITLE=").append(GetQ3Name()).append(".").append(parentDIA.Q3Scan).append(".").append(parentDIA.Q3Scan).append(".").append(mSMSProcessing.Precursorcluster.Charge).append("\n"); // //mgfString.append("TITLE=" + WindowID + ";ClusterIndex:" + mSMSProcessing.ms2cluster.Index + "\n"); // //mgfString.append("TITLE=" GetQ3Name() + WindowID + ";ClusterIndex:" + mSMSProcessing.ms2cluster.Index + "\n"); // // for (int i = 0; i < Scan.PointCount(); i++) { // mgfString.append(Scan.Data.get(i).getX()).append(" ").append(Scan.Data.get(i).getY()).append("\n"); // } // mgfString.append("END IONS\n\n"); // mgfWriter4.write(mgfString.toString()); mgfWriter4.append("BEGIN IONS\n") .append("PEPMASS=" + mSMSProcessing.Precursorcluster.TargetMz() + "\n") .append("CHARGE=" + mSMSProcessing.Precursorcluster.Charge + "+\n") .append("RTINSECONDS=" + mSMSProcessing.Precursorcluster.PeakHeightRT[0] * 60f + "\n") .append("TITLE=").append(GetQ3Name()).append(".").append(Integer.toString(parentDIA.Q3Scan)) .append(".").append(Integer.toString(parentDIA.Q3Scan)).append(".") .append(Integer.toString(mSMSProcessing.Precursorcluster.Charge)).append("\n"); //mgfWriter4.append("TITLE=" + WindowID + ";ClusterIndex:" + mSMSProcessing.ms2cluster.Index + "\n"); //mgfWriter4.append("TITLE=" GetQ3Name() + WindowID + ";ClusterIndex:" + mSMSProcessing.ms2cluster.Index + "\n"); for (int i = 0; i < Scan.PointCount(); i++) { mgfWriter4.append(Float.toString(Scan.Data.get(i).getX())).append(" ") .append(Float.toString(Scan.Data.get(i).getY())).append("\n"); } mgfWriter4.append("END IONS\n\n"); mapwriter3.write( parentDIA.Q3Scan + ";" + WindowID + ";" + mSMSProcessing.Precursorcluster.Index + "\n"); } mSMSProcessing.Precursorcluster.GroupedFragmentPeaks.clear(); } // mgfWriter4.close(); // mapwriter3.close(); }
From source file:MSUmpire.LCMSPeakStructure.LCMSPeakBase.java
private void JavaSerializationPeakClusterWrite() { try {// w w w . j ava 2s . co m Logger.getRootLogger().info("Writing PeakCluster serialization to file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser..."); FileOutputStream fout = new FileOutputStream( FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser", false); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(PeakClusters); oos.close(); fout.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); } }
From source file:com.google.gdt.eclipse.designer.hosted.tdt.HostedModeSupport.java
/** * @return the {@link ClassLoader} for accessing gwt-dev classes mixed with design-time support * lib.// w ww .ja v a 2s . co m */ private ClassLoader getDevClassLoader0() throws Exception { // prepare gwt-dev.jar location String devLibLocation = Utils.getDevLibLocation(moduleDescription); if (devLibLocation == null) { throw new HostedModeException(HostedModeException.NO_DEV_LIB); } String gwtLocation = FilenameUtils.getFullPath(devLibLocation); // add 'dev' & 'dev-designtime' ClassLoader devClassLoader = devClassLoaders.get(gwtLocation); if (devClassLoader == null) { URL resolvedDevLibUrl = new File(devLibLocation).toURI().toURL(); Bundle bundle = Activator.getDefault().getBundle(); URL devDesignUrl = FileLocator.resolve(bundle.getEntry("/gwt-dev-designtime.jar")); if (devDesignUrl != null) { // workaround for Issue 258 (https://code.google.com/p/google-plugin-for-eclipse/issues/detail?id=258) devDesignUrl = new URL(StringUtils.replace(devDesignUrl.toString(), " ", "%20")); } devClassLoader = new URLClassLoader(new URL[] { devDesignUrl, resolvedDevLibUrl }, null); devClassLoaders.put(gwtLocation, devClassLoader); } return devClassLoader; }
From source file:MSUmpire.DIA.DIAPack.java
public String GetiProphExtPepxml(String tag) { return FilenameUtils.separatorsToUnix(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + tag + ".iproph.pep.xml"); }
From source file:MSUmpire.PSMDataStructure.LCMSID.java
private void ExportPepPSMCSV(String folder) throws IOException { if (folder == null | "".equals(folder)) { folder = FilenameUtils.getFullPath(mzXMLFileName); }//from w w w . j a v a 2 s . c o m Logger.getRootLogger().info( "Writing PSM result to file:" + folder + FilenameUtils.getBaseName(mzXMLFileName) + "_PSMs.csv..."); FileWriter writer = new FileWriter(folder + FilenameUtils.getBaseName(mzXMLFileName) + "_PSMs.csv"); writer.write( "SpecID,Sequence,ModSeq,TPPModSeq,Modification,Charge,mz,NeutralPepMass,ObservedMass,RT,AdjustedRT,Rank,ScanNo,PreAA,NextAA,MissedCleavage,ExpectValue,MassError,Prob,Rawname,ParentPepIndex,MS1Quant\n"); for (PepIonID pepion : PepIonList.values()) { for (PSM psm : pepion.GetPSMList()) { writer.write(psm.SpecNumber + "," + psm.Sequence + "," + psm.ModSeq + "," + psm.TPPModSeq + "," + psm.GetModificationString() + "," + psm.Charge + "," + psm.ObserPrecursorMz() + "," + psm.NeutralPepMass + "," + psm.ObserPrecursorMass + "," + psm.RetentionTime + "," + psm.NeighborMaxRetentionTime + "," + psm.Rank + "," + psm.ScanNo + "," + psm.PreAA + "," + psm.NextAA + "," + psm.MissedCleavage + "," + psm.expect + "," + psm.MassError + "," + psm.Probability + "," + psm.RawDataName + "," + pepion.Index + "," + pepion.GetMS1() + "\n"); } } writer.close(); }
From source file:it.geosolutions.geobatch.task.TaskExecutor.java
private String setScriptArguments(final String defaultScriptPath, final String inputFilePath, String outputName, final File outXmlFile) throws IOException { String destFilePath = null;/*from ww w. j a v a2s. c o m*/ boolean overwriteOutput = false; if (outputName != null && outputName.trim().length() > 0) { overwriteOutput = true; if (outputName.startsWith("*.")) { final String outputExt = outputName.substring(2, outputName.length()); destFilePath = new StringBuilder(FilenameUtils.getFullPath(inputFilePath)).append(File.separator) .append(FilenameUtils.getBaseName(inputFilePath)).append(".").append(outputExt).toString(); } else { destFilePath = new StringBuilder(FilenameUtils.getFullPath(inputFilePath)).append(File.separator) .append(FilenameUtils.getBaseName(inputFilePath)).append(".").append(outputName).toString(); } } // Create FileReader Object FileReader inputFileReader = new FileReader(defaultScriptPath); FileWriter outputFileWriter = new FileWriter(outXmlFile); try { // Create Buffered/PrintWriter Objects BufferedReader inputStream = new BufferedReader(inputFileReader); PrintWriter outputStream = new PrintWriter(outputFileWriter); String inLine = null; boolean sourcePresent = false; boolean destinationPresent = false; while ((inLine = inputStream.readLine()) != null) { // Handle KeyWords if (inLine.trim().startsWith(SOURCE_TAG_OPEN)) { if (inLine.trim().endsWith(SOURCE_TAG_CLOSE)) { // source file specified on the same line inLine = new StringBuilder(SOURCE_TAG_OPEN).append(inputFilePath).append(SOURCE_TAG_CLOSE) .toString(); } else { while ((inLine = inputStream.readLine()) != null) { if (inLine.trim().endsWith(SOURCE_TAG_CLOSE)) { // source file specified on different lines inLine = new StringBuilder(SOURCE_TAG_OPEN).append(inputFilePath) .append(SOURCE_TAG_CLOSE).toString(); } } } sourcePresent = true; } if (inLine.trim().startsWith(DESTINATION_TAG_OPEN)) { if (inLine.trim().endsWith(DESTINATION_TAG_CLOSE)) { // source file specified on the same line if (overwriteOutput) { inLine = new StringBuilder(DESTINATION_TAG_OPEN).append(destFilePath) .append(DESTINATION_TAG_CLOSE).toString(); } else { final int start = inLine.indexOf(DESTINATION_TAG_OPEN); final int end = inLine.indexOf(DESTINATION_TAG_CLOSE, start + 1); destFilePath = inLine.substring(start + DESTINATION_TAG_OPEN.length(), end); } } else { while ((inLine = inputStream.readLine()) != null) { if (overwriteOutput) { if (inLine.trim().endsWith(DESTINATION_TAG_CLOSE)) { // source file specified on different lines inLine = new StringBuilder(DESTINATION_TAG_OPEN).append(destFilePath) .append(DESTINATION_TAG_CLOSE).toString(); } } else { String newLine = inLine.trim(); if (newLine.trim().endsWith(DESTINATION_TAG_CLOSE)) { // source file specified on different lines if (!newLine.trim().startsWith(DESTINATION_TAG_CLOSE)) { destFilePath = newLine.substring(0, newLine.indexOf(DESTINATION_TAG_CLOSE)); } } else { if (newLine.length() > 0) { destFilePath = newLine; } } } } } destinationPresent = true; } outputStream.println(inLine); } if (sourcePresent && !destinationPresent) { destFilePath = inputFilePath; } } catch (IOException e) { } finally { try { inputFileReader.close(); } catch (IOException e) { } try { outputFileWriter.close(); } catch (IOException e) { } } return destFilePath; }
From source file:MSUmpire.DIA.DIAPack.java
public String GetQ1Pepxml() { return FilenameUtils.separatorsToUnix(FilenameUtils.getFullPath(Filename) + "interact-" + FilenameUtils.getBaseName(GetQ1Name()) + ".pep.xml"); }
From source file:MSUmpire.LCMSPeakStructure.LCMSPeakMS1.java
public void GenerateMassCalibrationRTMap() throws IOException { String pngfile = FilenameUtils.getFullPath(ScanCollectionName) + "/" + FilenameUtils.getBaseName(ScanCollectionName) + "_masscaliRT.png"; XYSeries series = new XYSeries("PSM"); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); LoessInterpolator loessInterpolator = new LoessInterpolator(0.75, //bandwidth, 2//robustnessIters );//from ww w.j a v a 2s . c om for (PSM psm : this.IDsummary.PSMList.values()) { float ppm = InstrumentParameter.CalcSignedPPM(psm.ObserPrecursorMass, psm.NeutralPepMass); series.add(new XYDataItem(psm.RetentionTime, ppm)); } double x[] = new double[IDsummary.PSMList.size()]; double y[] = new double[x.length]; double currentmin = 0f; for (int i = 0; i < series.getItemCount(); i++) { x[i] = (double) series.getX(i); if (x[i] <= currentmin) { x[i] = currentmin + 0.0001f; } currentmin = x[i]; y[i] = (double) series.getY(i); } Masscalibrationfunction = loessInterpolator.interpolate(x, y); XYSeries smoothline = new XYSeries("Loess Regression"); double xvalue = x[0]; while (xvalue < x[x.length - 1]) { smoothline.add(xvalue, Masscalibrationfunction.value(xvalue)); xvalue += 0.05d; } xySeriesCollection.addSeries(smoothline); xySeriesCollection.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Mass calibration", "RT", "Mass error (ppm)", xySeriesCollection, PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(1, Color.blue); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesShape(1, new Ellipse2D.Double(0, 0, 3, 3)); renderer.setSeriesStroke(1, new BasicStroke(1.0f)); xyPlot.setBackgroundPaint(Color.white); ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600); }
From source file:MSUmpire.DIA.DIAPack.java
public String GetQ2Pepxml() { return FilenameUtils.separatorsToUnix(FilenameUtils.getFullPath(Filename) + "interact-" + FilenameUtils.getBaseName(GetQ2Name()) + ".pep.xml"); }
From source file:MSUmpire.LCMSPeakStructure.LCMSPeakBase.java
private boolean JavaSerializationPeakClusterRead() { if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser").exists()) { return false; }//from www . jav a 2 s. co m try { Logger.getRootLogger().info("Reading PeakCluster serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser..."); FileInputStream fileIn = new FileInputStream( FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.ser"); ObjectInputStream in = new ObjectInputStream(fileIn); PeakClusters = (ArrayList<PeakCluster>) in.readObject(); in.close(); fileIn.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return false; } return true; }