<commit_before>/**
 * Copyright © 2011-2014 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.web.pojo;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.WordUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uk.ac.ebi.phenotype.pojo.Allele;
import uk.ac.ebi.phenotype.pojo.GenomicFeature;
import uk.ac.ebi.phenotype.pojo.OntologyTerm;
import uk.ac.ebi.phenotype.pojo.Parameter;
import uk.ac.ebi.phenotype.pojo.Procedure;
import uk.ac.ebi.phenotype.pojo.ZygosityType;

/**
 * 
 * Represents a single row in a phenotype table
 * 
 */
public class PhenotypeRow implements Comparable<PhenotypeRow>{
	
	private final Logger log = LoggerFactory.getLogger(PhenotypeRow.class);

	private OntologyTerm phenotypeTerm;
	private GenomicFeature gene;
	private Allele allele;
	private List<String> sexes;
	private ZygosityType zygosity;
	private String rawZygosity;
	private int projectId;
	private String phenotypingCenter;
	private Procedure procedure;
	private Parameter parameter;
	private String dataSourceName;//to hold the name of the origin of the data e.g. Europhenome or WTSI Mouse Genetics Project

	private Integer pipelineStableKey;
	

	/**
	 * Returns a PhenotypeRow object with the original data provider link
	 * populated.
	 * 
	 * @param pr The original phenotype row object
	 * @return
	 */
	public String getPhenotypeLink() {

		String linkUrl="";

		if(getDataSourceName().equals("EuroPhenome")){
			String sex="";
			if(getSexes().size()==2){
				sex="Both-Split";
			}else{
				Iterator<String> iter = getSexes().iterator();
				String first = (String) iter.next();
				sex=WordUtils.capitalize(first);
			}
			try {
				linkUrl="http://www.europhenome.org/databrowser/viewer.jsp?set=true&m=true&l="+getProjectId()+"&zygosity="+getRawZygosity()+"&x="+sex+"&p="+getProcedure().getStableId()+"&pid_"+getParameter().getStableId()+"=on&compareLines=View+Data";
			} catch (NullPointerException e) {
				log.error("Project: "+getProjectId());
				log.error("Zygosity: "+getRawZygosity());
				log.error("Procedure: "+getProcedure());
				log.error("Parameter: "+getParameter());
				linkUrl = "";
			}
		}

		if(getDataSourceName().equals("WTSI Mouse Genetics Project")){
			
			if(getAllele()!=null  && getAllele().getGene()!=null){
				linkUrl="http://www.sanger.ac.uk/mouseportal/search?query="+getAllele().getGene().getSymbol();
			}

		}

		return linkUrl;
	}
	
	public String getPhenotypingCenter(){<commit_msg>removed method for constructing links to hughs europhenome charts<commit_after>/**
 * Copyright © 2011-2014 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.web.pojo;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.WordUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import uk.ac.ebi.phenotype.pojo.Allele;
import uk.ac.ebi.phenotype.pojo.GenomicFeature;
import uk.ac.ebi.phenotype.pojo.OntologyTerm;
import uk.ac.ebi.phenotype.pojo.Parameter;
import uk.ac.ebi.phenotype.pojo.Procedure;
import uk.ac.ebi.phenotype.pojo.ZygosityType;

/**
 * 
 * Represents a single row in a phenotype table
 * 
 */
public class PhenotypeRow implements Comparable<PhenotypeRow>{
	
	private final Logger log = LoggerFactory.getLogger(PhenotypeRow.class);

	private OntologyTerm phenotypeTerm;
	private GenomicFeature gene;
	private Allele allele;
	private List<String> sexes;
	private ZygosityType zygosity;
	private String rawZygosity;
	private int projectId;
	private String phenotypingCenter;
	private Procedure procedure;
	private Parameter parameter;
	private String dataSourceName;//to hold the name of the origin of the data e.g. Europhenome or WTSI Mouse Genetics Project

	private Integer pipelineStableKey;
	
	public String getPhenotypingCenter(){
{'fraction_non_alphanumeric': 0.10735264330565121, 'fraction_numerical': 0.005874012558233745, 'mean_word_length': 4.5545556805399325, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1216434', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1492, 'n_words': 434}