<commit_before>package org.modmine.web;

/*
 * Copyright (C) 2002-2010 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.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.lang.StringUtils;
import org.intermine.model.bio.Experiment;
import org.intermine.model.bio.ExperimentalFactor;
import org.intermine.model.bio.Project;
import org.intermine.model.bio.Submission;
import org.intermine.objectstore.ObjectStore;
import org.intermine.util.StringUtil;


/**
 * Wrap an experiment and its submissions to make display code simpler.
 * @author <NAME>
 *
 */
public class DisplayExperiment
{

    private String name;
    private List<Submission> submissions = new ArrayList<Submission>();
    private String projectName;
    private String pi;
    private String description = null;
    private Set<String> factorTypes = new TreeSet<String>(new FactorTypeComparator());
    private Set<String> organisms = new HashSet<String>();
    private Set<FeatureCountsRecord> featureCountsRecords =
        new LinkedHashSet<FeatureCountsRecord>();
    private ObjectStore os;
    private String experimentType;
    private String experimentCategory;
    private Set<String> labs = new TreeSet<String>();
    private String piSurname;

    /**
     * Construct with objects from database and feature counts summary map.
     * @param exp the experiment
     * @param project the experiment's project
     * @param featureCountsRecords a set of FeatureCountsRecord
     * @param os the objectstore
     */
    public DisplayExperiment(Experiment exp, Project project,
            Set<FeatureCountsRecord> featureCountsRecords, ObjectStore os) {
        initialise(exp, project);
        this.featureCountsRecords = featureCountsRecords;
        this.os = os;
    }

    private void initialise(Experiment exp, Project proj) {
        this.name = exp.getName();
        if (name.indexOf('&') > 0) {
            name = name.substring(0, name.indexOf('&'));
        }

        this.pi = proj.getNamePI() + " " + proj.getSurnamePI();
        this.piSurname = proj.getSurnamePI();
        if (!StringUtils.isBlank(proj.getName())) {
            this.projectName = proj.getName();
        } else {
            // This is a temporary fix for modMine 20 to cope with un-merged Projects
            if ("Celniker".equals(piSurname)) {
                this.projectName = "The Drosophila Transcriptome";
            } else if ("Waterston".equals(piSurname)) {
                this.projectName = "The C. elegans Transcriptome";
            } else if ("Lai".equals(piSurname)) {
                this.projectName = "Small and microRNAs";
            } else if ("Oliver".equals(piSurname)) {
                this.projectName = "Comparative Genomics";
            } else if ("Piano".equals(piSurname)) {
                this.projectName = "The 3' UTRome";
            }
        }

        Set<String> expTypes = new HashSet<String>();

        for (Submission submission : exp.getSubmissions()) {
            if (this.description == null) {
                this.description = submission.getDescription();
            }
            submissions.add(submission);
            labs.add(submission.getLab().getName());<commit_msg>More changes to deal with un-merged Projects.<commit_after>package org.modmine.web;

/*
 * Copyright (C) 2002-2010 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.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import org.apache.commons.lang.StringUtils;
import org.intermine.model.bio.Experiment;
import org.intermine.model.bio.ExperimentalFactor;
import org.intermine.model.bio.Lab;
import org.intermine.model.bio.Project;
import org.intermine.model.bio.Submission;
import org.intermine.objectstore.ObjectStore;
import org.intermine.util.StringUtil;


/**
 * Wrap an experiment and its submissions to make display code simpler.
 * @author <NAME>
 *
 */
public class DisplayExperiment
{

    private String name;
    private List<Submission> submissions = new ArrayList<Submission>();
    private String projectName;
    private String pi;
    private String description = null;
    private Set<String> factorTypes = new TreeSet<String>(new FactorTypeComparator());
    private Set<String> organisms = new HashSet<String>();
    private Set<FeatureCountsRecord> featureCountsRecords =
        new LinkedHashSet<FeatureCountsRecord>();
    private ObjectStore os;
    private String experimentType;
    private String experimentCategory;
    private Set<String> labs = new TreeSet<String>();
    private String piSurname;

    /**
     * Construct with objects from database and feature counts summary map.
     * @param exp the experiment
     * @param project the experiment's project
     * @param featureCountsRecords a set of FeatureCountsRecord
     * @param os the objectstore
     */
    public DisplayExperiment(Experiment exp, Project project,
            Set<FeatureCountsRecord> featureCountsRecords, ObjectStore os) {
        initialise(exp, project);
        this.featureCountsRecords = featureCountsRecords;
        this.os = os;
    }

    private void initialise(Experiment exp, Project proj) {
        this.name = exp.getName();
        if (name.indexOf('&') > 0) {
            name = name.substring(0, name.indexOf('&'));
        }

        this.pi = (proj.getNamePI() == null ? "" : proj.getNamePI() + " ") + proj.getSurnamePI();
        this.piSurname = proj.getSurnamePI();
        if (!StringUtils.isBlank(proj.getName())) {
            this.projectName = proj.getName();
        } else {
            // This is a temporary fix for modMine 20 to cope with un-merged Projects
            if ("Celniker".equals(piSurname)) {
                this.projectName = "The Drosophila Transcriptome";
            } else if ("Waterston".equals(piSurname)) {
                this.projectName = "The C. elegans Transcriptome";
            } else if ("Lai".equals(piSurname)) {
                this.projectName = "Small and microRNAs";
            } else if ("Oliver".equals(piSurname)) {
                this.projectName = "Comparative Genomics";
            } else if ("Piano".equals(piSurname)) {
                this.projectName = "The 3' UTRome";
            }
        }

        Set<String> expTypes = new HashSet<String>();

        for (Submission submission : exp.getSubmissions()) {
            if (this.description == null) {
                this.description = submission.getDescription();
            }
            submissions.add(submission);
            Lab lab = submission.getLab();
            if (lab.getName() != null) {
                labs.add(submission.getLab().getName());
            } else {
                labs.add(lab.getSurname());
            }
{'fraction_non_alphanumeric': 0.10611103714551991, 'fraction_numerical': 0.00346158966848622, 'mean_word_length': 2.7710843373493974, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3868922', 'n_tokens_mistral': 2142, 'n_tokens_neox': 2031, 'n_words': 555}