<commit_before>/**
 * Copyright (c) 2011 <NAME> and <NAME>
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.semanticscience.narf.graphs.nucleicacid;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org._3pq.jgrapht.graph.SimpleGraph;
import org.openscience.cdk.annotations.TestClass;
import org.semanticscience.narf.structures.interactions.BasePair;
import org.semanticscience.narf.structures.interactions.BaseStack;
import org.semanticscience.narf.structures.interactions.NucleotideInteraction;
import org.semanticscience.narf.structures.interactions.PhosphodiesterBond;
import org.semanticscience.narf.structures.parts.Nucleotide;
import org.semanticscience.narf.structures.parts.Sequence;
import org.semanticscience.narf.structures.secondary.SecondaryStructure;

/**
 * Representation of a nucleic acid as an undirected graph that has no loops and
 * at most one edge between any two vertices. The vertices represent nucleotide
 * residues and the edges represent interaction(s) between two nucleotide
 * residues. One Nucleic Acid object will represent one model of a structure in
 * the case of a multi-module structure
 * 
 * @author "<NAME>"
 * @since 1.6
 */

public class NucleicAcid extends AbstractNucleicAcid  {

	private static final long serialVersionUID = 2692448232910041821L;

	/**
	 * Model number of a nucleic acid conformer. Multiple possible conformations
	 * can occur from one structure. This number should correspond to either the
	 * model number in an NMR ensemble or a unique integer for identifying a
	 * predicted nucleic acid from an ensemble of predictions.
	 */
	public int modelNumber;

	/**
	 * A set of all the interactions found in the graph.
	 */
	private Set<NucleotideInteraction> interactions;

	/**
	 * A mapping of the chain identifier to a sequence object representing the
	 * chain.
	 */
	private Map<String, Sequence> chain2SequenceMap;

	/**
	 * A mapping of the chain identifier to the set of interactions in and on
	 * the chain. Each set of interactions for a chain contains intra- and
	 * inter-chain interactions.
	 */
	private Map<String, Set<NucleotideInteraction>> chain2InteractionMap;
	
	

	/**
	 * Construct a nucleic acid using a mapping of chains to their respective
	 * sequences and a set of interactions that occur in the nucleic acid. The
	 * minimum cyclic motif graph is also constructed to find all the structural
	 * motifs in the graph.
	 * 
	 * @param aModelNumber
	 *            the model number of this structural conformation
	 * @param aSequenceMap
	 *            a mapping of the chain to its respective sequence
	 * @param someInteractions
	 *            a set of interactions present in the nucleic acid
	 * @throws InvalidPhosphodiesterBondException
	 * @since 1.6
	 */
	public NucleicAcid(int aModelNumber, Map<String, Sequence> aSequenceMap,
			Set<NucleotideInteraction> someInteractions) {
		this.modelNumber = aModelNumber;
		this.chain2SequenceMap = aSequenceMap;
		this.interactions = someInteractions;
		this.chain2InteractionMap = makeChain2InteractionMap(aSequenceMap,<commit_msg>added list cycle instance variable<commit_after>/**
 * Copyright (c) 2011 <NAME> and <NAME>
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.semanticscience.narf.graphs.nucleicacid;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org._3pq.jgrapht.graph.SimpleGraph;
import org.openscience.cdk.annotations.TestClass;
import org.semanticscience.narf.graphs.lib.cycles.Cycle;
import org.semanticscience.narf.structures.interactions.BasePair;
import org.semanticscience.narf.structures.interactions.BaseStack;
import org.semanticscience.narf.structures.interactions.NucleotideInteraction;
import org.semanticscience.narf.structures.interactions.PhosphodiesterBond;
import org.semanticscience.narf.structures.parts.Nucleotide;
import org.semanticscience.narf.structures.parts.Sequence;
import org.semanticscience.narf.structures.secondary.SecondaryStructure;

/**
 * Representation of a nucleic acid as an undirected graph that has no loops and
 * at most one edge between any two vertices. The vertices represent nucleotide
 * residues and the edges represent interaction(s) between two nucleotide
 * residues. One Nucleic Acid object will represent one model of a structure in
 * the case of a multi-module structure
 * 
 * @author "<NAME>"
 * @since 1.6
 */

public class NucleicAcid extends AbstractNucleicAcid  {

	private static final long serialVersionUID = 2692448232910041821L;

	/**
	 * Model number of a nucleic acid conformer. Multiple possible conformations
	 * can occur from one structure. This number should correspond to either the
	 * model number in an NMR ensemble or a unique integer for identifying a
	 * predicted nucleic acid from an ensemble of predictions.
	 */
	public int modelNumber;

	/**
	 * A set of all the interactions found in the graph.
	 */
	private Set<NucleotideInteraction> interactions;

	/**
	 * A mapping of the chain identifier to a sequence object representing the
	 * chain.
	 */
	private Map<String, Sequence> chain2SequenceMap;

	/**
	 * A mapping of the chain identifier to the set of interactions in and on
	 * the chain. Each set of interactions for a chain contains intra- and
	 * inter-chain interactions.
	 */
	private Map<String, Set<NucleotideInteraction>> chain2InteractionMap;
	/**
	 * The minimum cycle basis computed for this nucleic acid 
	 * Uses the CDK ringsearch implementation of Horton 1984
	 */
	private List<Cycle<Nucleotide, InteractionEdge>> minimumCycleBasis;	

	/**
	 * Construct a nucleic acid using a mapping of chains to their respective
	 * sequences and a set of interactions that occur in the nucleic acid. The
	 * minimum cyclic motif graph is also constructed to find all the structural
	 * motifs in the graph.
	 * 
	 * @param aModelNumber
	 *            the model number of this structural conformation
	 * @param aSequenceMap
	 *            a mapping of the chain to its respective sequence
	 * @param someInteractions
	 *            a set of interactions present in the nucleic acid
	 * @throws InvalidPhosphodiesterBondException
	 * @since 1.6
	 */
	public NucleicAcid(int aModelNumber, Map<String, Sequence> aSequenceMap,
			Set<NucleotideInteraction> someInteractions) {
		this.modelNumber = aModelNumber;
		this.chain2SequenceMap = aSequenceMap;
		this.interactions = someInteractions;
		this.chain2InteractionMap = makeChain2InteractionMap(aSequenceMap,
{'fraction_non_alphanumeric': 0.06466643936811, 'fraction_numerical': 0.007955449482895784, 'mean_word_length': 4.35931790499391, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7490996', 'n_tokens_mistral': 2502, 'n_tokens_neox': 2225, 'n_words': 972}