<commit_before>/*******************************************************************************
 * Copyright 2015 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License.
 *******************************************************************************/
package uk.ac.ebi.phenotype.chart;

import org.apache.commons.lang.WordUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.mousephenotype.cda.db.pojo.DiscreteTimePoint;
import org.mousephenotype.cda.db.pojo.Parameter;
import org.mousephenotype.cda.enumerations.SexType;
import org.mousephenotype.cda.enumerations.ZygosityType;
import org.mousephenotype.cda.solr.service.ImpressService;
import org.mousephenotype.cda.solr.service.dto.ExperimentDTO;
import org.mousephenotype.cda.solr.service.dto.ObservationDTO;
import org.mousephenotype.cda.solr.service.dto.ParameterDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;




@Service
public class TimeSeriesChartAndTableProvider {

	
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass().getCanonicalName());

	public ChartData doTimeSeriesOverviewData(
			Map<String, List<DiscreteTimePoint>> lines, Parameter p) {

		if (lines == null) {
			return new ChartData();
		}

		String title = p.getName();
		// create CharData
		ChartData chartsNTablesForParameter = creatDiscretePointTimeSeriesChartOverview(
				"1", title, lines, p.checkParameterUnit(1),
				p.checkParameterUnit(2), 1, "org", p);
		return chartsNTablesForParameter;
	}



	public ChartData doTimeSeriesData(ExperimentDTO experiment,	ParameterDTO parameter, String experimentNumber)
	throws IOException,	URISyntaxException {

		ChartData chartNTableForParameter = null;
		Map<String, List<DiscreteTimePoint>> lines = new TreeMap<String, List<DiscreteTimePoint>>();

		for (SexType sex : experiment.getSexes()) {

			List<DiscreteTimePoint> controlDataPoints = new ArrayList<>();

			for (ObservationDTO control : experiment.getControls()) {
				String docGender = control.getSex();

				if (SexType.valueOf(docGender).equals(sex)) {
					Float dataPoint = control.getDataPoint();
					logger.debug("data value=" + dataPoint);
					Float discreteTimePoint = control.getDiscretePoint();

					// Ensure the timepoint is valid
					if (discreteTimePoint > 0) {<commit_msg>Add 0 timepoint for ! BWT parameters<commit_after>/*******************************************************************************
 * Copyright 2015 EMBL - European Bioinformatics Institute
 *
 * Licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific
 * language governing permissions and limitations under the
 * License.
 *******************************************************************************/
package uk.ac.ebi.phenotype.chart;

import org.apache.commons.lang.WordUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.mousephenotype.cda.db.pojo.DiscreteTimePoint;
import org.mousephenotype.cda.db.pojo.Parameter;
import org.mousephenotype.cda.enumerations.SexType;
import org.mousephenotype.cda.enumerations.ZygosityType;
import org.mousephenotype.cda.solr.service.ImpressService;
import org.mousephenotype.cda.solr.service.dto.ExperimentDTO;
import org.mousephenotype.cda.solr.service.dto.ObservationDTO;
import org.mousephenotype.cda.solr.service.dto.ParameterDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;




@Service
public class TimeSeriesChartAndTableProvider {

	
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass().getCanonicalName());

	public ChartData doTimeSeriesOverviewData(
			Map<String, List<DiscreteTimePoint>> lines, Parameter p) {

		if (lines == null) {
			return new ChartData();
		}

		String title = p.getName();
		// create CharData
		ChartData chartsNTablesForParameter = creatDiscretePointTimeSeriesChartOverview(
				"1", title, lines, p.checkParameterUnit(1),
				p.checkParameterUnit(2), 1, "org", p);
		return chartsNTablesForParameter;
	}



	public ChartData doTimeSeriesData(ExperimentDTO experiment,	ParameterDTO parameter, String experimentNumber)
	throws IOException,	URISyntaxException {

		ChartData chartNTableForParameter = null;
		Map<String, List<DiscreteTimePoint>> lines = new TreeMap<String, List<DiscreteTimePoint>>();

		for (SexType sex : experiment.getSexes()) {

			List<DiscreteTimePoint> controlDataPoints = new ArrayList<>();

			for (ObservationDTO control : experiment.getControls()) {
				String docGender = control.getSex();

				if (SexType.valueOf(docGender).equals(sex)) {
					Float dataPoint = control.getDataPoint();
					logger.debug("data value=" + dataPoint);
					Float discreteTimePoint = control.getDiscretePoint();

					// Ensure the timepoint is valid
					if (discreteTimePoint >= 0 || ! parameter.getStableId().contains("BWT")) {
{'fraction_non_alphanumeric': 0.1451265927519444, 'fraction_numerical': 0.005129902366374318, 'mean_word_length': 5.322175732217573, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5714441', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1667, 'n_words': 442}