public DotBracketNotation(Sequence aSequence, String aDotBracketNotation)
			throws InvalidDotBracketNotationException {
		if (aSequence.getLength() != aDotBracketNotation.length()) {
			throw new InvalidDotBracketNotationException(
					"Sequence and dot bracket notation are not the same length.");
		}

		if (!this.isNested(aSequence, aDotBracketNotation)) {
			throw new InvalidDotBracketNotationException(
					"The dot bracket notation contains non properly nested characters");
		}

		this.sequence = aSequence;
		this.dotBracketNotation = aDotBracketNotation;
		this.interactions = new LinkedHashSet<NucleotideInteraction>();
		this.dotBracketMap = new LinkedHashMap<Nucleotide, Character>();

		Iterator<Nucleotide> itr = this.sequence.iterator();

		LinkedHashMap<Character, Stack<Nucleotide>> openingStacks = new LinkedHashMap<Character, Stack<Nucleotide>>();

		// iterate over the sequence, ensure that dbn is nested and create base
		// pairs and add them to the interactions set
		int i = 0;
		while (itr.hasNext()) {

			Nucleotide currentNucleotide = itr.next();
			char dotBracket = this.dotBracketNotation.charAt(i++);

			dotBracketMap.put(currentNucleotide, dotBracket);

			if (this.isOpeningCharacter(dotBracket)) {
				if (!openingStacks.containsKey(dotBracket)) {
					openingStacks.put(dotBracket, new Stack<Nucleotide>());
				}

				openingStacks.get(dotBracket).push(currentNucleotide);
			} else if (this.isClosingCharacter(dotBracket)) {
				Stack<Nucleotide> openingStack = openingStacks
						.get(DotBracketNotationConstants.CLOSING_CHARACTERS
								.get(dotBracket));

				BasePair bp = new BasePair(openingStack.pop(),
						currentNucleotide);
				this.interactions.add(bp);
			} else {
				continue;
			}

		}

		for (int j = 0; j < this.sequence.getLength() - 1; j++) {
			Nucleotide curr = this.sequence.getNucleotideAtPosition(j + 1);
			Nucleotide next = this.sequence.getNucleotideAtPosition(j + 2);
			// check if the two nucleotides have a difference of one in their
			// positions
			int check = next.getResiduePosition() - curr.getResiduePosition();
			if (check == 1) {
				PhosphodiesterBond pdb = null;
				try {
					pdb = new PhosphodiesterBond(curr, next);
				} catch (NonConsecutiveNucleotideException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

				this.interactions.add(pdb);

			}
		}

	}