<commit_before>package gov.nih.nci.nautilus.queryprocessing.ge;

import gov.nih.nci.nautilus.criteria.GeneIDCriteria;
import gov.nih.nci.nautilus.de.GeneIdentifierDE;
import gov.nih.nci.nautilus.de.BasePairPositionDE;
import gov.nih.nci.nautilus.data.*;
import gov.nih.nci.nautilus.queryprocessing.QueryHandler;
import gov.nih.nci.nautilus.queryprocessing.cgh.CGHReporterIDCriteria;
import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.query.ReportQueryByCriteria;
import org.apache.ojb.broker.query.QueryFactory;
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerFactory;

import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.math.BigDecimal;

/**
 * Created by IntelliJ IDEA.
 * User: BhattarR
 * Date: Sep 10, 2004
 * Time: 4:22:02 PM
 * To change this template use Options | File Templates.
 */
public class GeneIDCriteriaHandler {

     static HashMap data = new HashMap();
        static {
            data.put(GeneIdentifierDE.GeneSymbol.class.getName(),
                            new TargetClass(GeneSnp.class, GeneSnp.SNP_PROBESET_ID));
            data.put(GeneIdentifierDE.LocusLink.class.getName(),
                            new TargetClass(LlSnp.class, LlSnp.SNP_PROBESET_ID));
            data.put(GeneIdentifierDE.GenBankAccessionNumber.class.getName(),
                            new TargetClass(GeneSnp.class, GeneSnp.SNP_PROBESET_ID));
        }
    /*public static GEReporterIDCriteria buildGeneIDCriteria( GeneIDCriteria  geneIDCrit, boolean includeClones, boolean includeProbes, PersistenceBroker pb ) throws Exception {

        Class deClass = getGeneIDClassName(geneIDCrit);
        ArrayList geneIDs = getGeneIDValues(geneIDCrit);

        return buildReporterIDCritForGEQuery(deClass,geneIDs, includeClones, includeProbes, pb);
     }*/

    private static ArrayList getGeneIDValues(GeneIDCriteria geneIDCrit) {
        Collection geneIdDEs = geneIDCrit.getGeneIdentifiers();
        ArrayList geneIDs = new ArrayList();
        for (Iterator iterator = geneIdDEs.iterator(); iterator.hasNext();) {
            GeneIdentifierDE obj  = (GeneIdentifierDE) iterator.next();
            String value = null;
            if (obj.getGeneIDType().equals(GeneIdentifierDE.GENESYMBOL))
               value = obj.getValueObject().toUpperCase();
            else value = obj.getValueObject();
            geneIDs.add(((GeneIdentifierDE) iterator.next()).getValueObject());
        }
        return geneIDs;
    }


    public static CGHReporterIDCriteria  buildReporterIDCritForCGHQuery(GeneIDCriteria  geneIDCrit, boolean includeSNPs, boolean includeCGH, PersistenceBroker pb) throws Exception {<commit_msg>removed the extra iterator next from the loop which was causing out of bound<commit_after>package gov.nih.nci.nautilus.queryprocessing.ge;

import gov.nih.nci.nautilus.criteria.GeneIDCriteria;
import gov.nih.nci.nautilus.de.GeneIdentifierDE;
import gov.nih.nci.nautilus.de.BasePairPositionDE;
import gov.nih.nci.nautilus.data.*;
import gov.nih.nci.nautilus.queryprocessing.QueryHandler;
import gov.nih.nci.nautilus.queryprocessing.cgh.CGHReporterIDCriteria;
import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.query.ReportQueryByCriteria;
import org.apache.ojb.broker.query.QueryFactory;
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerFactory;

import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.HashMap;
import java.math.BigDecimal;

/**
 * Created by IntelliJ IDEA.
 * User: BhattarR
 * Date: Sep 10, 2004
 * Time: 4:22:02 PM
 * To change this template use Options | File Templates.
 */
public class GeneIDCriteriaHandler {

     static HashMap data = new HashMap();
        static {
            data.put(GeneIdentifierDE.GeneSymbol.class.getName(),
                            new TargetClass(GeneSnp.class, GeneSnp.SNP_PROBESET_ID));
            data.put(GeneIdentifierDE.LocusLink.class.getName(),
                            new TargetClass(LlSnp.class, LlSnp.SNP_PROBESET_ID));
            data.put(GeneIdentifierDE.GenBankAccessionNumber.class.getName(),
                            new TargetClass(GeneSnp.class, GeneSnp.SNP_PROBESET_ID));
        }
    /*public static GEReporterIDCriteria buildGeneIDCriteria( GeneIDCriteria  geneIDCrit, boolean includeClones, boolean includeProbes, PersistenceBroker pb ) throws Exception {

        Class deClass = getGeneIDClassName(geneIDCrit);
        ArrayList geneIDs = getGeneIDValues(geneIDCrit);

        return buildReporterIDCritForGEQuery(deClass,geneIDs, includeClones, includeProbes, pb);
     }*/

    private static ArrayList getGeneIDValues(GeneIDCriteria geneIDCrit) {
        Collection geneIdDEs = geneIDCrit.getGeneIdentifiers();
        ArrayList geneIDs = new ArrayList();
        for (Iterator iterator = geneIdDEs.iterator(); iterator.hasNext();) {
            GeneIdentifierDE obj  = (GeneIdentifierDE) iterator.next();
            String value = null;
            if (obj.getGeneIDType().equals(GeneIdentifierDE.GENESYMBOL))
               value = obj.getValueObject().toUpperCase();
            else value = obj.getValueObject();
            geneIDs.add(value);//no need to call next again, just set the value
        }
        return geneIDs;
    }


    public static CGHReporterIDCriteria  buildReporterIDCritForCGHQuery(GeneIDCriteria  geneIDCrit, boolean includeSNPs, boolean includeCGH, PersistenceBroker pb) throws Exception {
{'fraction_non_alphanumeric': 0.09430636347611493, 'fraction_numerical': 0.0038780186849991186, 'mean_word_length': 3.5684380032206118, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6648728', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1675, 'n_words': 323}