<commit_before>/*
 *                    BioJava development code
 *
 * 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.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 * Created on May 27, 2010
 * Author: <NAME> 
 *
 */

package org.biojava3.protmod;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * This class contains information about a specific protein
 * modification. 
 * 
 * @author <NAME>
 * @since 3.0
 */
public class ProteinModificationImpl 
implements ProteinModification {
	
	private final String id;	
	private final ModificationCondition condition;
	private final ModificationCategory category;
	private final ModificationOccurrenceType occurrenceType;
	
	private final String pdbccId;
	private final String pdbccName;
	private final String residId;
	private final String residName;
	private final String psimodId;
	private final String psimodName;
	private final String sysName;
	private final String formula;
	private final String description;
	private final Set<String> keywords;

	public String getId() {
		return id;
	}
	
	public String getPdbccId() {
		return pdbccId;
	}
	
	public String getPdbccName() {
		return pdbccName;
	}
	
	public String getResidId() {
		return residId;
	}
	
	public String getResidName() {
		return residName;
	}
	
	public String getPsimodId() {
		return psimodId;
	}
	
	public String getPsimodName() {
		return psimodName;
	}
	
	public String getSystematicName() {
		return sysName;
	}
	
	public String getDescription() {
		return toString();
		//return description;
	}
	
	public Set<String> getKeywords() {
		return keywords;
	}
	
	public ModificationCondition getCondition() {
		return condition;
	}
	
	public String getFormula() {
		return formula;
	}
	
	public ModificationCategory getCategory() {
		return category;
	}
	
	public ModificationOccurrenceType getOccurrenceType() {
		return occurrenceType;
	}
	
	@Override
	public String toString() {
		return printModification(this);
//		StringBuilder sb = new StringBuilder();
//		
//		sb.append("ID:"+getId());
//		sb.append("\nPDBCC ID:"+getPdbccId());
//		sb.append("\tPDBCC name:"+getPdbccName());
//		sb.append("\nRESID ID:"+getResidId());
//		sb.append("\tRESID name:"+getResidName());
//		sb.append("\nPSI-MOD ID:"+getPsimodId());
//		sb.append("\tPSI-MOD name:"+getPsimodName());
//		sb.append("\nDescription:"+getDescription());
//		sb.append("\nSystematic name:"+getSystematicName());
//		sb.append("\nCategory:"+getCategory().label());
//		sb.append("\nOccurrence type:"+getOccurrenceType().label());
//		sb.append("\nKeywords:"+getKeywords());
//		sb.append("\nCondition:"+getCondition());
//		return sb.toString();
	}
	
	private String printModification(ProteinModificationImpl mod) {
		StringBuilder sb = new StringBuilder();
						
		String name = getBestPossibleName(mod);
		boolean hasName = true;
		if (  name.equals(""))
			hasName = false;
		sb.append(name);
		
		Set<String> keywords = mod.getKeywords();
		if (keywords!=null && !keywords.isEmpty()) {
			if ( hasName)
				sb.append(", ");
			for (String keyword : keywords) {
				
				sb.append(keyword);
				sb.append(", ");
			}
			sb.delete(sb.length()-2,sb.length());
		}
	
		return sb.toString();
	}
	
	private String getBestPossibleName(ProteinModificationImpl mod) {
		
		//System.out.println(mod.getResidName() + " : " + mod.getPsimodName() + " : " + mod.getPdbccName() + " : " + mod.getSystematicName());
		
		// first: get resid<commit_msg>slightly different toString<commit_after>/*
 *                    BioJava development code
 *
 * 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.  If you do not have a copy,
 * see:
 *
 *      http://www.gnu.org/copyleft/lesser.html
 *
 * Copyright for this code is held jointly by the individual
 * authors.  These should be listed in @author doc comments.
 *
 * For more information on the BioJava project and its aims,
 * or to join the biojava-l mailing list, visit the home page
 * at:
 *
 *      http://www.biojava.org/
 *
 * Created on May 27, 2010
 * Author: <NAME> 
 *
 */

package org.biojava3.protmod;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * This class contains information about a specific protein
 * modification. 
 * 
 * @author <NAME>
 * @since 3.0
 */
public class ProteinModificationImpl 
implements ProteinModification {
	
	private final String id;	
	private final ModificationCondition condition;
	private final ModificationCategory category;
	private final ModificationOccurrenceType occurrenceType;
	
	private final String pdbccId;
	private final String pdbccName;
	private final String residId;
	private final String residName;
	private final String psimodId;
	private final String psimodName;
	private final String sysName;
	private final String formula;
	private final String description;
	private final Set<String> keywords;

	public String getId() {
		return id;
	}
	
	public String getPdbccId() {
		return pdbccId;
	}
	
	public String getPdbccName() {
		return pdbccName;
	}
	
	public String getResidId() {
		return residId;
	}
	
	public String getResidName() {
		return residName;
	}
	
	public String getPsimodId() {
		return psimodId;
	}
	
	public String getPsimodName() {
		return psimodName;
	}
	
	public String getSystematicName() {
		return sysName;
	}
	
	public String getDescription() {
		return toString();
		//return description;
	}
	
	public Set<String> getKeywords() {
		return keywords;
	}
	
	public ModificationCondition getCondition() {
		return condition;
	}
	
	public String getFormula() {
		return formula;
	}
	
	public ModificationCategory getCategory() {
		return category;
	}
	
	public ModificationOccurrenceType getOccurrenceType() {
		return occurrenceType;
	}
	
	@Override
	public String toString() {
		return printModification(this);
//		StringBuilder sb = new StringBuilder();
//		
//		sb.append("ID:"+getId());
//		sb.append("\nPDBCC ID:"+getPdbccId());
//		sb.append("\tPDBCC name:"+getPdbccName());
//		sb.append("\nRESID ID:"+getResidId());
//		sb.append("\tRESID name:"+getResidName());
//		sb.append("\nPSI-MOD ID:"+getPsimodId());
//		sb.append("\tPSI-MOD name:"+getPsimodName());
//		sb.append("\nDescription:"+getDescription());
//		sb.append("\nSystematic name:"+getSystematicName());
//		sb.append("\nCategory:"+getCategory().label());
//		sb.append("\nOccurrence type:"+getOccurrenceType().label());
//		sb.append("\nKeywords:"+getKeywords());
//		sb.append("\nCondition:"+getCondition());
//		return sb.toString();
	}
	
	private String printModification(ProteinModificationImpl mod) {
		StringBuilder sb = new StringBuilder();
						
		String name = getBestPossibleName(mod);
		boolean hasName = true;
		if (  name.equals(""))
			hasName = false;
		sb.append(name);
		
		Set<String> keywords = mod.getKeywords();
		if (keywords!=null && !keywords.isEmpty()) {
			if ( hasName)
				sb.append(" (");
			for (String keyword : keywords) {
				
				sb.append(keyword);
				sb.append(", ");
			}
			sb.delete(sb.length()-2,sb.length());
		}
		if ( hasName)
			sb.append(")");
		return sb.toString();
	}
	
	private String getBestPossibleName(ProteinModificationImpl mod) {
		
		//System.out.println(mod.getResidName() + " : " + mod.getPsimodName() + " : " + mod.getPdbccName() + " : " + mod.getSystematicName());
		
		// first: get resid
{'fraction_non_alphanumeric': 0.1295376385173863, 'fraction_numerical': 0.0025474461851993377, 'mean_word_length': 3.7329716696805306, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5631838', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2474, 'n_words': 648}