<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/
 *
 */

package org.biojava.nbio.structure.symmetry.core;

import org.biojava.nbio.structure.symmetry.geometry.MomentsOfInertia;
import org.biojava.nbio.structure.symmetry.geometry.SuperPosition;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import java.util.*;
import java.util.Map.Entry;


/**
 * A bean to represent info about the set of subunits being considered for a
 * QuatSymmetryDetector alignment.
 * @author <NAME>
 */
public class Subunits {
	private List<Point3d[]> caCoords = Collections.emptyList();
	private List<Integer> sequenceClusterIds = Collections.emptyList();
	private List<Boolean> pseudoStoichiometry = Collections.emptyList();
	private List<Double> minSequenceIdentity = Collections.emptyList();
	private List<Double> maxSequenceIdentity = Collections.emptyList();
	private List<String> chainIds = Collections.emptyList();
	private List<Integer> modelNumbers =  Collections.emptyList();
	private List<Integer> folds = Collections.emptyList();
	private List<Point3d> originalCenters = new ArrayList<Point3d>();
	private List<Point3d> centers = new ArrayList<Point3d>();
	private List<Vector3d> unitVectors = new ArrayList<Vector3d>();
	private int nucleicAcidChainCount = 0;
	private boolean pseudoSymmetric = false;

	private Point3d centroid;
	private MomentsOfInertia momentsOfInertia = new MomentsOfInertia();

	/**
	 * All inputs should contain one element per subunit.
	 * @param caCoords CA coordinates of all subunits
	 * @param sequenceClusterIds ID of the cluster that each subunit belongs to
	 * @param pseudoStoichiometry Whether pseudosymmetry was used when clustering the subunit
	 * @param minSequenceIdentity Minimum sequence identity to other cluster members
	 * @param maxSequenceIdentity Maximum sequence identity to other cluster members
	 * @param folds Valid symmetry orders for this stoichiometry
	 * @param chainIds Chain ID for the subunit
	 * @param modelNumbers Model number for the subunit
	 */
	public Subunits(List<Point3d[]> caCoords, List<Integer> sequenceClusterIds, List<Boolean> pseudoStoichiometry, List<Double> minSequenceIdentity, List<Double> maxSequenceIdentity, List<Integer> folds, List<String> chainIds, List<Integer> modelNumbers) {
		this.caCoords = caCoords;
		this.sequenceClusterIds = sequenceClusterIds;
		this.pseudoStoichiometry = pseudoStoichiometry;
		this.minSequenceIdentity = minSequenceIdentity;
		this.maxSequenceIdentity = maxSequenceIdentity;
		this.folds = folds;
		this.chainIds = chainIds;
		this.modelNumbers = modelNumbers;
	}

	public List<Point3d[]> getTraces() {
		return caCoords;
	}

	public int getSubunitCount() {
		run();
		if (centers == null) {
			return 0;
		}
		return centers.size();
	}

	public List<Integer> getSequenceClusterIds() {
		return sequenceClusterIds;
	}

	public boolean isPseudoStoichiometric() {
		for (Boolean b: pseudoStoichiometry) {<commit_msg>Catching empty coordinates earlier in quat sym detection<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/
 *
 */

package org.biojava.nbio.structure.symmetry.core;

import org.biojava.nbio.structure.symmetry.geometry.MomentsOfInertia;
import org.biojava.nbio.structure.symmetry.geometry.SuperPosition;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import java.util.*;
import java.util.Map.Entry;


/**
 * A bean to represent info about the set of subunits being considered for a
 * QuatSymmetryDetector alignment.
 * @author <NAME>
 */
public class Subunits {
	private List<Point3d[]> caCoords = Collections.emptyList();
	private List<Integer> sequenceClusterIds = Collections.emptyList();
	private List<Boolean> pseudoStoichiometry = Collections.emptyList();
	private List<Double> minSequenceIdentity = Collections.emptyList();
	private List<Double> maxSequenceIdentity = Collections.emptyList();
	private List<String> chainIds = Collections.emptyList();
	private List<Integer> modelNumbers =  Collections.emptyList();
	private List<Integer> folds = Collections.emptyList();
	private List<Point3d> originalCenters = new ArrayList<Point3d>();
	private List<Point3d> centers = new ArrayList<Point3d>();
	private List<Vector3d> unitVectors = new ArrayList<Vector3d>();
	private int nucleicAcidChainCount = 0;
	private boolean pseudoSymmetric = false;

	private Point3d centroid;
	private MomentsOfInertia momentsOfInertia = new MomentsOfInertia();

	/**
	 * All inputs should contain one element per subunit.
	 * @param caCoords CA coordinates of all subunits
	 * @param sequenceClusterIds ID of the cluster that each subunit belongs to
	 * @param pseudoStoichiometry Whether pseudosymmetry was used when clustering the subunit
	 * @param minSequenceIdentity Minimum sequence identity to other cluster members
	 * @param maxSequenceIdentity Maximum sequence identity to other cluster members
	 * @param folds Valid symmetry orders for this stoichiometry
	 * @param chainIds Chain ID for the subunit
	 * @param modelNumbers Model number for the subunit
	 */
	public Subunits(List<Point3d[]> caCoords, List<Integer> sequenceClusterIds, List<Boolean> pseudoStoichiometry, List<Double> minSequenceIdentity, List<Double> maxSequenceIdentity, List<Integer> folds, List<String> chainIds, List<Integer> modelNumbers) {
		
		for (int i=0; i<caCoords.size(); i++) {
			if (caCoords.get(i).length==0) 
				throw new IllegalArgumentException("0-length coordinate array in subunit coordinates with index " +i+". Can't calculate quaternary symmetry for empty coordinates.");
		}
		
		this.caCoords = caCoords;
		this.sequenceClusterIds = sequenceClusterIds;
		this.pseudoStoichiometry = pseudoStoichiometry;
		this.minSequenceIdentity = minSequenceIdentity;
		this.maxSequenceIdentity = maxSequenceIdentity;
		this.folds = folds;
		this.chainIds = chainIds;
		this.modelNumbers = modelNumbers;
	}

	public List<Point3d[]> getTraces() {
		return caCoords;
	}

	public int getSubunitCount() {
		run();
		if (centers == null) {
			return 0;
		}
		return centers.size();
	}

	public List<Integer> getSequenceClusterIds() {
		return sequenceClusterIds;
	}

	public boolean isPseudoStoichiometric() {
		for (Boolean b: pseudoStoichiometry) {
{'fraction_non_alphanumeric': 0.08843724251579237, 'fraction_numerical': 0.004257072232903049, 'mean_word_length': 4.798566878980892, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 53, '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': '6651694', 'n_tokens_mistral': 2167, 'n_tokens_neox': 2009, 'n_words': 662}