/*
 * The Exomiser - A tool to annotate and prioritize genomic variants
 *
 * Copyright (c) 2016-2018 Queen Mary University of London.
 * Copyright (c) 2012-2016 Charité Universitätsmedizin Berlin and Genome Research Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.monarchinitiative.exomiser.data.phenotype.parsers;

import org.monarchinitiative.exomiser.data.phenotype.resources.Resource;
import org.monarchinitiative.exomiser.data.phenotype.resources.ResourceOperationStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;

/**
 * Parse the good old human-phenotype-ontology.obo file (or alternatively the
 * hp.obo file from our Hudson server). We want to create a table in the
 * database with lcname - HP:id - preferred name, where lcname is the lower-case
 * name or synonym, ID is the HPO id, and preferred name is the HPO Term name.
 * We lower-case the name ans synonyms to be able to search only over lower
 * cased names for the autosuggestion. However, we want to display the preferred
 * name in the end.
 *
 * @author Peter Robinson
 * @version 0.04 (27 November, 2013)
 */
public class ZPOntologyFileParser implements ResourceParser {

    private static final Logger logger = LoggerFactory.getLogger(ZPOntologyFileParser.class);

    private final Map<String, String> zpId2termMap;

    public ZPOntologyFileParser(Map<String, String> zpId2termMap) {
        this.zpId2termMap = zpId2termMap;
    }

    /**
     * This function does the actual work of parsing the HPO file.
     *
     * @param resource
     * @param inDir    Complete path to directory containing the human-phenotype-ontology.obo or hp.obo file.
     * @param outDir   Directory where output file is to be written
     * @return
     */
    @Override
    public void parseResource(Resource resource, Path inDir, Path outDir) {

        Path inFile = inDir.resolve(resource.getExtractedFileName());
        Path outFile = outDir.resolve(resource.getParsedFileName());

        logger.info("Parsing {} file: {}. Writing out to: {}", resource.getName(), inFile, outFile);
        ResourceOperationStatus status;

        try (BufferedReader reader = Files.newBufferedReader(inFile, Charset.forName("UTF-8"));
             BufferedWriter writer = Files.newBufferedWriter(outFile, Charset.defaultCharset())) {
            String line;
            while ((line = reader.readLine()) != null) {
                String[] fields = line.split("\\t");
                if (fields[0].startsWith("ZP:")) {
                    zpId2termMap.put(fields[0], fields[1]);
                    writer.write(String.format("%s|%s", fields[0], fields[1]));
                    writer.newLine();
                }
            }
            status = ResourceOperationStatus.SUCCESS;
        } catch (FileNotFoundException ex) {
            logger.error(null, ex);
            status = ResourceOperationStatus.FILE_NOT_FOUND;
        } catch (IOException ex) {
            logger.error(null, ex);
            status = ResourceOperationStatus.FAILURE;
        }
        resource.setParseStatus(status);
        logger.info("{}", status);
    }
}
@@ -1423,558 +1423,18 @@
 %0A * 
-Parse the good old human-phenotype-ontology.obo file (or alternatively the%0A * hp.obo file from our Hudson server). We want to create a table in the%0A * database with lcname - HP:id - preferred name, where lcname is the lower-case%0A * name or synonym, ID is the HPO id, and preferred name is the HPO Term name.%0A * We lower-case the name ans synonyms to be able to search only over lower%0A * cased names for the autosuggestion. However, we want to display the preferred%0A * name in the end.%0A *%0A * @author Peter Robinson%0A * @version 0.04 (27 November, 2013)
+ZPO parser
 %0A */
@@ -1936,41 +1936,9 @@
 the 
-human-phenotype-ontology.obo or h
+z
 p.ob

Remove incorrect copy-pasted java doc from ZPOntologyParser