Package com.compomics.util.experiment.io.identifications

Examples of com.compomics.util.experiment.io.identifications.IdfileReader


            identification = proteomicAnalysis.getIdentification(IdentificationMethod.MS2_IDENTIFICATION);
            waitingHandler.setSecondaryProgressCounterIndeterminate(true);
            waitingHandler.appendReport("Parsing " + idFile.getName() + ".", true, true);

            IdfileReader fileReader = null;
            try {
                fileReader = readerFactory.getFileReader(idFile);
            } catch (OutOfMemoryError error) {
                waitingHandler.appendReport("Ran out of memory when parsing \'" + Util.getFileName(idFile) + "\'.", true, true);
                throw new OutOfMemoryError("Ran out of memory when parsing \'" + Util.getFileName(idFile) + "\'.");
            }

            if (fileReader == null) {
                waitingHandler.appendReport("Identification result file \'" + Util.getFileName(idFile) + "\' not recognized.", true, true);
                waitingHandler.setRunCanceled();
                return;
            }

            // Clear cache for sequencing files. TODO: make something more generic?
            if (idFile.getName().endsWith("tags")) {
                if (tagMapper == null) {
                    tagMapper = new TagMapper(proteinTree, searchParameters, sequenceMatchingPreferences, annotationPreferences, exceptionHandler);
                }
                if (!peptideShaker.getCache().isEmpty()) {
                    peptideShaker.getCache().reduceMemoryConsumption(0.9, waitingHandler);
                }
            }

            waitingHandler.setSecondaryProgressCounterIndeterminate(false);

            LinkedList<SpectrumMatch> idFileSpectrumMatches = null;
            try {
                if (peptideMapper != null && !peptideMapper.isCanceled()) {
                    idFileSpectrumMatches = fileReader.getAllSpectrumMatches(waitingHandler, sequenceMatchingPreferences, true);
                } else {
                    idFileSpectrumMatches = fileReader.getAllSpectrumMatches(waitingHandler, null, true);
                }
            } catch (Exception e) {
                waitingHandler.appendReport("An error occurred while loading spectrum matches from \'"
                        + Util.getFileName(idFile)
                        + "\'. This file will be ignored. Error: " + e.getMessage()
                        + " See resources/PeptideShaker.log for details.", true, true);
                e.printStackTrace();
            }

            // set the search engine name and version for this file
            HashMap<String, ArrayList<String>> software = fileReader.getSoftwareVersions();
            projectDetails.setIdentificationAlgorithmsForFile(Util.getFileName(idFile), software);

            fileReader.close();

            if (idFileSpectrumMatches != null) {

                boolean allLoaded = true;
                int numberOfMatches = idFileSpectrumMatches.size();
                waitingHandler.setMaxSecondaryProgressCounter(numberOfMatches);
                waitingHandler.appendReport("Loading spectra for " + idFile.getName() + ".", true, true);
                for (SpectrumMatch spectrumMatch : idFileSpectrumMatches) {
                    if (!importSpectrum(idFile, spectrumMatch, numberOfMatches)) {
                        allLoaded = false;
                        String fileName = Spectrum.getSpectrumFile(spectrumMatch.getKey());
                        waitingHandler.appendReport(fileName + " missing.", true, true);
                    }
                    waitingHandler.increaseSecondaryProgressCounter();
                }

                if (allLoaded) {

                    // Map spectrum sequencing matches on protein sequences
                    if (tagMapper != null) {
                        tagMapper.mapTags(fileReader, waitingHandler, processingPreferences.getnThreads());
                    }

                    // Map the peptides on protein sequences
                    if (peptideMapper != null) {
                        try {
                            if (!peptideMapper.isCanceled()) {
                                peptideMapper.mapPeptides(fileReader.getPeptidesMap(), sequenceMatchingPreferences, idFilter, processingPreferences.getnThreads(), waitingHandler);
                            }
                            if (peptideMapper.isCanceled()) {
                                fileReader.clearPeptidesMap();
                            }
                        } catch (OutOfMemoryError e) {
                            e.printStackTrace();
                            fileReader.clearPeptidesMap();
                        }
                    }
                    // empty protein caches
                    if (MemoryConsumptionStatus.memoryUsed() > 0.8) {
                        ProteinTreeComponentsFactory.getInstance().getCache().reduceMemoryConsumption(1, null);
View Full Code Here


        IdfileReaderFactory idFileReaderFactory = IdfileReaderFactory.getInstance();
        ArrayList<File> idFiles = identificationFiles;
        for (File idFile : idFiles) {
            String idFileName = Util.getFileName(idFile);
            try {
                IdfileReader idFileReader = idFileReaderFactory.getFileReader(idFile);
                identificationAlgorithms.put(idFileName, idFileReader.getSoftwareVersions());
            } catch (Exception e) {
                // File was moved, use the extension to map it manually
                Advocate advocate = Advocate.getAdvocateFromFile(idFileName);
                if (advocate != null) {
                    HashMap<String, ArrayList<String>> algorithms = new HashMap<String, ArrayList<String>>();
View Full Code Here

TOP

Related Classes of com.compomics.util.experiment.io.identifications.IdfileReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.