<commit_before>package org.intermine.bio.dataconversion;

/*
 * Copyright (C) 2002-2015 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */


import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.keyvalue.MultiKey;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.tools.ant.BuildException;
import org.intermine.dataconversion.ItemWriter;
import org.intermine.metadata.ConstraintOp;
import org.intermine.metadata.Model;
import org.intermine.model.bio.Organism;
import org.intermine.model.bio.Protein;
import org.intermine.objectstore.ObjectStore;
import org.intermine.objectstore.ObjectStoreException;
import org.intermine.objectstore.ObjectStoreFactory;
import org.intermine.objectstore.query.BagConstraint;
import org.intermine.objectstore.query.ConstraintSet;
import org.intermine.objectstore.query.ContainsConstraint;
import org.intermine.objectstore.query.Query;
import org.intermine.objectstore.query.QueryClass;
import org.intermine.objectstore.query.QueryField;
import org.intermine.objectstore.query.QueryObjectReference;
import org.intermine.objectstore.query.Results;
import org.intermine.objectstore.query.ResultsRow;
import org.intermine.util.FormattedTextParser;
import org.intermine.xml.full.Item;

/**
 * This parser is use for parsing protein domain assignments and
 * protein domain locations in protein2ipr.dat form InterPro. <br/>
 * The file could be found at: <br/>
 * ftp://ftp.ebi.ac.uk/pub/databases/interpro/Current/protein2ipr.dat.gz
 * <p>
 * Because the file includes proteins in all species,
 * the parser will only load the proteins of the specified species which are already loaded into
 *  the mine.
 * Thus, better to run after the unirpot data source.
 * In addition, protein domain information are loaded by the interpro data source.
 * (both are kindly shared by InterMine.) </p>
 *
 * @author chenyian
 */
public class Protein2iprConverter extends BioFileConverter
{

    private static final Logger LOG = Logger.getLogger(Protein2iprConverter.class);
    private static final String DATASET_TITLE = "InterPro data set";
    private static final String DATA_SOURCE_NAME = "InterPro";

    private Collection<Integer> taxonIds = new ArrayList<Integer>();

    private Set<String> proteinIds = new HashSet<String>();
    private Set<MultiKey> xrefs = new HashSet<MultiKey>();
    private Map<String, String> proteinMap = new HashMap<String, String>();
    private Map<String, String> proteinDomainMap = new HashMap<String, String>();

    /**
     * @param taxonIds set valid taxonIds to process<commit_msg>corrects typo<commit_after>package org.intermine.bio.dataconversion;

/*
 * Copyright (C) 2002-2015 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */


import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import org.apache.commons.collections.keyvalue.MultiKey;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.tools.ant.BuildException;
import org.intermine.dataconversion.ItemWriter;
import org.intermine.metadata.ConstraintOp;
import org.intermine.metadata.Model;
import org.intermine.model.bio.Organism;
import org.intermine.model.bio.Protein;
import org.intermine.objectstore.ObjectStore;
import org.intermine.objectstore.ObjectStoreException;
import org.intermine.objectstore.ObjectStoreFactory;
import org.intermine.objectstore.query.BagConstraint;
import org.intermine.objectstore.query.ConstraintSet;
import org.intermine.objectstore.query.ContainsConstraint;
import org.intermine.objectstore.query.Query;
import org.intermine.objectstore.query.QueryClass;
import org.intermine.objectstore.query.QueryField;
import org.intermine.objectstore.query.QueryObjectReference;
import org.intermine.objectstore.query.Results;
import org.intermine.objectstore.query.ResultsRow;
import org.intermine.util.FormattedTextParser;
import org.intermine.xml.full.Item;

/**
 * This parser is use for parsing protein domain assignments and
 * protein domain locations in protein2ipr.dat form InterPro. <br/>
 * The file could be found at: <br/>
 * ftp://ftp.ebi.ac.uk/pub/databases/interpro/Current/protein2ipr.dat.gz
 * <p>
 * Because the file includes proteins in all species,
 * the parser will only load the proteins of the specified species which are already loaded into
 *  the mine.
 * Thus, better to run after the uniprot data source.
 * In addition, protein domain information are loaded by the interpro data source.
 * (both are kindly shared by InterMine.) </p>
 *
 * @author chenyian
 */
public class Protein2iprConverter extends BioFileConverter
{

    private static final Logger LOG = Logger.getLogger(Protein2iprConverter.class);
    private static final String DATASET_TITLE = "InterPro data set";
    private static final String DATA_SOURCE_NAME = "InterPro";

    private Collection<Integer> taxonIds = new ArrayList<Integer>();

    private Set<String> proteinIds = new HashSet<String>();
    private Set<MultiKey> xrefs = new HashSet<MultiKey>();
    private Map<String, String> proteinMap = new HashMap<String, String>();
    private Map<String, String> proteinDomainMap = new HashMap<String, String>();

    /**
     * @param taxonIds set valid taxonIds to process
{'fraction_non_alphanumeric': 0.09464882943143813, 'fraction_numerical': 0.004347826086956522, 'mean_word_length': 4.992985971943888, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6965738', 'n_tokens_mistral': 1740, 'n_tokens_neox': 1695, 'n_words': 492}