<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.jstacs.de/index.php?action=history&amp;feed=atom&amp;title=Starter%3A_Data_handling</id>
	<title>Starter: Data handling - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.jstacs.de/index.php?action=history&amp;feed=atom&amp;title=Starter%3A_Data_handling"/>
	<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;action=history"/>
	<updated>2026-04-04T16:05:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=537&amp;oldid=prev</id>
		<title>Grau at 08:41, 3 February 2012</title>
		<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=537&amp;oldid=prev"/>
		<updated>2012-02-03T08:41:54Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:41, 3 February 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l13&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;the alphabet. [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] s, [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s, and [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] s are immutable for reasons of security and data consistency. That means, an instance of those&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;the alphabet. [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] s, [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s, and [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] s are immutable for reasons of security and data consistency. That means, an instance of those&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;classes cannot be modified once it has been created.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;classes cannot be modified once it has been created.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;__TOC__&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Alphabets ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Alphabets ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Grau</name></author>
	</entry>
	<entry>
		<id>https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=521&amp;oldid=prev</id>
		<title>Grau at 14:25, 2 February 2012</title>
		<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=521&amp;oldid=prev"/>
		<updated>2012-02-02T14:25:12Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:25, 2 February 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;= Starter: Data handling =&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;span id=&amp;quot;data&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;span id=&amp;quot;data&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Grau</name></author>
	</entry>
	<entry>
		<id>https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=508&amp;oldid=prev</id>
		<title>Grau at 13:58, 2 February 2012</title>
		<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=508&amp;oldid=prev"/>
		<updated>2012-02-02T13:58:05Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;amp;diff=508&amp;amp;oldid=495&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Grau</name></author>
	</entry>
	<entry>
		<id>https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=495&amp;oldid=prev</id>
		<title>Grau: moved Cookbook – Starter: Data handling to Starter: Data handling</title>
		<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=495&amp;oldid=prev"/>
		<updated>2012-02-01T22:57:49Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/index.php/Cookbook_%E2%80%93_Starter:_Data_handling&quot; class=&quot;mw-redirect&quot; title=&quot;Cookbook – Starter: Data handling&quot;&gt;Cookbook – Starter: Data handling&lt;/a&gt; to &lt;a href=&quot;/index.php/Starter:_Data_handling&quot; title=&quot;Starter: Data handling&quot;&gt;Starter: Data handling&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:57, 1 February 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Grau</name></author>
	</entry>
	<entry>
		<id>https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=488&amp;oldid=prev</id>
		<title>Grau: Created page with &quot;&lt;span id=&quot;data&quot;&gt; &lt;/span&gt;  In Jstacs, data is organized at three levels:  * [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] s for defining single s...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.jstacs.de/index.php?title=Starter:_Data_handling&amp;diff=488&amp;oldid=prev"/>
		<updated>2012-02-01T22:49:53Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;span id=&amp;quot;data&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;  In Jstacs, data is organized at three levels:  * [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] s for defining single s...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;span id=&amp;quot;data&amp;quot;&amp;gt; &amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Jstacs, data is organized at three levels:&lt;br /&gt;
&lt;br /&gt;
* [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] s for defining single symbols, and [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer] s for defining aggregate alphabets,&lt;br /&gt;
* [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s for defining sequences of symbols over a given alphabet,&lt;br /&gt;
* [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] s for defining sets of sequences.&lt;br /&gt;
ginal symbols&lt;br /&gt;
using the alphabet. This mapping is also used for the &amp;lt;code&amp;gt;toString()&amp;lt;/code&amp;gt; method, e.g., for printing a sequence. The actual &lt;br /&gt;
data type, i.e. byte, short, or integer, used to represented the symbols is chosen internally depending on the size of &lt;br /&gt;
the alphabet. [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] s, [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s, and [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] s are immutable for reasons of security and data consistency. That means, an instance of those&lt;br /&gt;
classes cannot be modified once it has been created.&lt;br /&gt;
&lt;br /&gt;
== Alphabets ==&lt;br /&gt;
&lt;br /&gt;
Since Jstacs is tailored at sequence analysis in bioinformatics, the most prominent alphabet is the [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet], which is a singleton instance that can be accessed by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DNAAlphabet dna = DNAAlphabet.SINGLETON;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For general discrete alphabets, i.e., any kind of categorical data, you can use a [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DiscreteAlphabet.html DiscreteAlphabet]. Such an alphabet can be constructed in case-sensitive and insensitive variants (first argument) using a list of symbols.&lt;br /&gt;
In this example, we create a case-sensitive alphabet with symbols &amp;quot;W&amp;quot;, &amp;quot;S&amp;quot;, &amp;quot;w&amp;quot;, and &amp;quot;x&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DiscreteAlphabet discrete = new DiscreteAlphabet( false, &amp;quot;W&amp;quot;, &amp;quot;S&amp;quot;, &amp;quot;w&amp;quot;, &amp;quot;x&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you rather want to define an alphabet over contiguous discrete numerical values, you can do so by calling a constructor that takes&lt;br /&gt;
the minimum and maximum value of the desired range, and defines the alphabet as all integer values between minimum and&lt;br /&gt;
maximum (inclusive). For example, to create a discrete alphabet over the values from &amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;10&amp;lt;/math&amp;gt;, you can call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DiscreteAlphabet numerical = new DiscreteAlphabet( 3, 10 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuous alphabets are defined over all reals (minus infinity to infinity) by default (see first line in the following example).&lt;br /&gt;
However, if you want to define the continuous alphabet over a specific interval, you can specify the maximum and the minimum value of that interval. In the example, we define a continuous alphabet spanning all reals between &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;100&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		ContinuousAlphabet continuousInf = new ContinuousAlphabet();&lt;br /&gt;
		ContinuousAlphabet continuousPos = new ContinuousAlphabet( 0.0, 100.0 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the DNA alphabet, each symbols has a complementary counterpart. Since in some cases, a similar complementarity&lt;br /&gt;
can also be defined for symbols other than DNA-nucleotides (e.g., for RNA sequences containing U instead of T), Jstacs&lt;br /&gt;
allows to define generic complementable alphabets. These allow for example the generation of reverse complementary sequences&lt;br /&gt;
out of an existing sequence. Here, we define a binary alphabet of symbols &amp;amp;quot;A&amp;amp;quot; and &amp;amp;quot;B&amp;amp;quot;, where &amp;amp;quot;A&amp;amp;quot; is the complement of &amp;amp;quot;B&amp;amp;quot; and vice versa.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		GenericComplementableDiscreteAlphabet complementable = new GenericComplementableDiscreteAlphabet( true, new String[]{&amp;quot;A&amp;quot;,&amp;quot;B&amp;quot;}, new int[]{1,0} );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first parameter again defines if this alphabet is case-insensitive (which is the case), the second parameter defines the symbols of the alphabet, and the third parameter specifies the index of the complementary symbol. For instance, the symbol at position &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt; (&amp;amp;quot;B&amp;amp;quot;) is set as the complement of the symbol at position 0 (&amp;amp;quot;A&amp;amp;quot;) by setting the &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt;-th value of the integer array to &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
After the definition of single alphabets, we switch to the creation of aggregate alphabets. Almost everywhere in Jstacs, we use aggregate alphabets&lt;br /&gt;
to maintain generalizability. Since the aggregate alphabet containing only a [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet] is always the same, a singleton for such an [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer] is pre-defined:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		AlphabetContainer dnaContainer = DNAAlphabetContainer.SINGLETON;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can explicitly define an [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer] using a simple continuous alphabet by calling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		AlphabetContainer contContainer = new AlphabetContainer( continuousInf );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Aggregate alphabets become interesting if we need different symbols at different positions of a sequence, or even a mixture of discrete and continuous values.&lt;br /&gt;
For example, we might want to represent sequences that consist of a DNA-nucleotide at the first position, some other discrete symbol at the second position, and  a real number stemming from some measurement at the third position. Using the [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet], the discrete [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet], and the continuous [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] defined&lt;br /&gt;
above, we can define such an aggregate alphabet by calling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		AlphabetContainer mixedContainer = new AlphabetContainer(dna, discrete, continuousPos);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To save memory, we can also re-use the same alphabet at different position of the aggregate alphabet. If we want to use a [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet] at positions &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;1&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt;, and a continuous alphabet at positions &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;4&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt;, we can use a constructor that takes the alphabets as the first argument and the assignment to the positions as the second argument:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		AlphabetContainer complex = new AlphabetContainer( new Alphabet[]{dna,continuousInf}, new int[]{0,0,1,0,1,1} );		&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The alphabets are assigned to specific positions by their index in the array of the first argument.&lt;br /&gt;
&lt;br /&gt;
== Sequences ==&lt;br /&gt;
&lt;br /&gt;
Single sequences can be created from an [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer] and a string. However, in most cases, we load the data from some file, which will be explained&lt;br /&gt;
in the next sub-section.&lt;br /&gt;
For creating a DNA sequence, we use a [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet] like the one defined above and a string over the DNA alphabet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence dnaSeq = Sequence.create( dnaContainer, &amp;quot;ACGTACGTACGT&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In a similar manner, we define a continuous sequence. In this case, a single value is represented by more than one letter in the string. Hence, &lt;br /&gt;
we need to define a delimiter between the values as a third argument, which is a space in the example.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence contSeq = Sequence.create( contContainer, &amp;quot;0.5 1.32642 99.5 20.4 5 7.7&amp;quot; , &amp;quot; &amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can also create sequences over the mixed alphabet defined above. In the example, the single values are delimited by a &amp;amp;quot;;&amp;amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence mixedSeq = Sequence.create( mixedContainer, &amp;quot;C;x;5.67&amp;quot; , &amp;quot;;&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For very large amounts of data or very long sequences, even the representation of symbols by byte values can be too memory-consuming. Hence, &lt;br /&gt;
Jstacs also offers a representation of DNA sequences in a sparse encoding as bits of long values. You can create such a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/SparseSequence.html SparseSequence] from a [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet] &lt;br /&gt;
and a string:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence sparse = new SparseSequence( dnaContainer, &amp;quot;ACGTACGTACGT&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, the reduced memory footprint comes at the expense of a slightly increased runtime for accessing symbols of a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/SparseSequence.html SparseSequence]. Hence, it is not the default representation in Jstacs.&lt;br /&gt;
&lt;br /&gt;
After we learned how to create sequences, we now want to work with them. First of all, you can obtain the length of a sequence&lt;br /&gt;
from its &amp;lt;code&amp;gt;getLength()&amp;lt;/code&amp;gt; method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		int length = dnaSeq.getLength();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since on the abstract level of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] we do not distinguish between discrete and continuous sequences (and we also may have mixed sequences), there are&lt;br /&gt;
two alternative methods to obtain one element of a sequence regardless of its content. With the first method, we can obtain the discrete value at a certain position (2 in the example):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		int value = dnaSeq.discreteVal( 2 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] contains a continuous value at this position, it is discretized by default by returning the distance to the minimum value of the continuous alphabet&lt;br /&gt;
at this position casted to an integer. If the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] contains a discrete value, that value is just returned in the encoding according to the [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer].&lt;br /&gt;
In a similar manner, we can obtain the continuous value at a position (5 in the example)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		double value2 = contSeq.continuousVal( 5 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where discrete values are just casted to &amp;lt;code&amp;gt;double&amp;lt;/code&amp;gt;s.&lt;br /&gt;
&lt;br /&gt;
We can obtain a sub-sequence of a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] using the method &amp;lt;code&amp;gt;getSubSequence(int,int)&amp;lt;/code&amp;gt;, where the first parameter is the start position within the sequence, counting from &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt;, and the second&lt;br /&gt;
parameter is the length of the extracted sub-sequence. So the following line of code would extract a sub-sequence of length &amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt; starting at position &amp;lt;math&amp;gt;2&amp;lt;/math&amp;gt; of the original sequence or, stated differently,&lt;br /&gt;
we skip the first two elements, extract the following three elements, and again skip everything after position &amp;lt;math&amp;gt;4&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence contSub = contSeq.getSubSequence( 2, 3 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s in Jstacs are immutable, this method returns a new instance of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence], which is assigned to a variable &amp;lt;code&amp;gt;contSub&amp;lt;/code&amp;gt; in the example. Hence, in cases where you need&lt;br /&gt;
the same sub-sequences frequently in your code, for example in a ZOOPS-model or other models using sliding windows on a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence], we recommend to precompute these sub-sequences and store them in some auxiliary data structure in order to invest runtime in computations rather than garbage collection. Internally, sub-sequences only hold a reference on the original sequences and the start position and length within that sequence to keep the memory overhead of sub-sequences at a low level.&lt;br /&gt;
&lt;br /&gt;
For [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s defined over a [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/ComplementableDiscreteAlphabet.html ComplementableDiscreteAlphabet] like the [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/DNAAlphabet.html DNAAlphabet], we can also obtain the (reverse) complement of a sequence. For example, to create&lt;br /&gt;
the reverse complementary sequence of a complete sequence, we call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence revComp = dnaSeq.reverseComplement();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the complement of a sub-sequence of length &amp;lt;math&amp;gt;6&amp;lt;/math&amp;gt; starting at position &amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt; of the original sequence, we use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence subComp = dnaSeq.complement( 3, 6 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For some analyses, for instance permutation tests or for estimating false-positive rates of predictions, it is useful to create permuted variants of an original sequence.&lt;br /&gt;
To this end, Jstacs provides a class [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/PermutedSequence.html PermutedSequence] that creates a randomly permuted variant using the constructor&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		PermutedSequence permuted = new PermutedSequence( dnaSeq );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or a user-defined permutation by an alternative constructor. In the randomized variant, the positions of the original sequence are permuted independently of each other, which means that higher order properties of the sequence like di-nucleotide content are not preserved. If you want to create sequences with similar higher-order properties, have a look at the &amp;lt;code&amp;gt;emitSample()&amp;lt;/code&amp;gt; method of [http://www.jstacs.de/api-2.0//de/jstacs/sequenceScores/statisticalModels/trainable/discrete/homogeneous/HomogeneousModel.html HomogeneousModel].&lt;br /&gt;
&lt;br /&gt;
Often, we want to add additional annotations to a sequence, for instance the occurrences of some binding motif, start and end positions of introns, or just the species a sequence is stemming from. To this end, Jstacs provides a number of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SequenceAnnotation.html SequenceAnnotation] s that can be added to a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] (or read from a FastA-file as we will see later).&lt;br /&gt;
For instance, we can add the annotation for binding site of a motif called &amp;amp;quot;new motif&amp;amp;quot; of length &amp;lt;math&amp;gt;5&amp;lt;/math&amp;gt; starting at position &amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt; of the forward strand of sequence &amp;lt;code&amp;gt;dnaSeq&amp;lt;/code&amp;gt; using the &amp;lt;code&amp;gt;annotate&amp;lt;/code&amp;gt; method of that sequence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence annotatedDnaSeq = dnaSeq.annotate( true, new MotifAnnotation( &amp;quot;new motif&amp;quot;, 3, 5, Strand.FORWARD ) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Again, this method creates a new [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] object due to [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s being immutable.&lt;br /&gt;
After we added several [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SequenceAnnotation.html SequenceAnnotation] s to a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence], we can obtain all those annotations by calling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		SequenceAnnotation[] allAnnotations = annotatedDnaSeq.getAnnotation();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For retrieving annotations of a specific type, we can use the method &amp;lt;code&amp;gt;getSequenceAnnotationByType&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		MotifAnnotation motif = (MotifAnnotation) annotatedDnaSeq.getSequenceAnnotationByType( &amp;quot;Motif&amp;quot;, 0 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
to, for instance, obtain the first (index &amp;lt;math&amp;gt;0&amp;lt;/math&amp;gt;) annotation of type &amp;amp;quot;Motif&amp;amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== DataSets ==&lt;br /&gt;
In most cases, we want to load [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s from some FastA or plain text file instead of creating [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s manually from strings. In Jstacs, collections of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s are represented by&lt;br /&gt;
[http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] s. The class [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] (and [http://www.jstacs.de/api-2.0//de/jstacs/data/DNADataSet.html DNADataSet]) provide constructors that work on a file or the path to a file, and parse the contents of the file to a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet], i.e. a collection of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s.&lt;br /&gt;
&lt;br /&gt;
The most simple case is to create a [http://www.jstacs.de/api-2.0//de/jstacs/data/DNADataSet.html DNADataSet] from a FastA file. To do so, we call the constructor of [http://www.jstacs.de/api-2.0//de/jstacs/data/DNADataSet.html DNADataSet] with the (absolute or relative) path to the FastA file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DNADataSet dnaDataSet = new DNADataSet( &amp;quot;myfile.fa&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For other file formats and types of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s, [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] provides another constructor that works on the [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer] for the data in the file, a [http://www.jstacs.de/api-2.0//de/jstacs/io/StringExtractor.html StringExtractor] that handles the extraction of&lt;br /&gt;
the strings representing single sequences and skipping comment lines, and a delimiter between the elements of a sequence. Hence, the [http://www.jstacs.de/api-2.0//de/jstacs/io/StringExtractor.html StringExtractor], a [http://www.jstacs.de/api-2.0//de/jstacs/io/SparseStringExtractor.html SparseStringExtractor] in the example, requires the specification of the path to the file and the symbol that indicates comment line. For example, if we want to create a sample of continuous sequences stored in a tab-separated plain text file &amp;amp;quot;myfile.tab&amp;amp;quot;, we use the [http://www.jstacs.de/api-2.0//de/jstacs/data/AlphabetContainer.html AlphabetContainer] with a continuous [http://www.jstacs.de/api-2.0//de/jstacs/data/alphabets/Alphabet.html Alphabet] from above, a [http://www.jstacs.de/api-2.0//de/jstacs/io/StringExtractor.html StringExtractor] with a hash as the comment symbol, and a tab as the delimiter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet contDataSet = new DataSet( contContainer, new SparseStringExtractor( &amp;quot;myfile.tab&amp;quot;, &amp;#039;#&amp;#039; ), &amp;quot;\t&amp;quot; );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [http://www.jstacs.de/api-2.0//de/jstacs/io/SparseStringExtractor.html SparseStringExtractor] is tailored to files containing many sequences, and reads the file line by line, where each line is converted to a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] and discarded before the next line is parsed.&lt;br /&gt;
&lt;br /&gt;
Since [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/SparseSequence.html SparseSequence] s are not one of the default representations of sequence in Jstacs (see above), these are not created by the constructors of [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] or [http://www.jstacs.de/api-2.0//de/jstacs/data/DNADataSet.html DNADataSet]. However, the class [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/SparseSequence.html SparseSequence] provides a method &amp;lt;code&amp;gt;getSample&amp;lt;/code&amp;gt; that takes the same arguments as the constructor of [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet], for example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet sparseDataSet = SparseSequence.getDataSet( dnaContainer, new SparseStringExtractor( &amp;quot;myfile.fa&amp;quot;, &amp;#039;&amp;gt;&amp;#039; ) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
for reading DNA sequences from a FastA file, and returns a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] containing [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/SparseSequence.html SparseSequence] s.&lt;br /&gt;
&lt;br /&gt;
After we successfully created a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet], we want to access and use the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s within this [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet]. We retrieve a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] of a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] using the method &amp;lt;code&amp;gt;getElementAt(int)&amp;lt;/code&amp;gt;. For instance,&lt;br /&gt;
we get the fifth [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] of &amp;lt;code&amp;gt;dnaSample&amp;lt;/code&amp;gt; by calling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		Sequence fifth = dnaDataSet.getElementAt( 5 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can also request the number of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s in a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] by the method &amp;lt;code&amp;gt;getNumberOfElements()&amp;lt;/code&amp;gt; and use this information, for instance, to&lt;br /&gt;
iterate over all [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s. In the example, we just print the retrieved [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s to standard out&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		for(int i=0;i&amp;lt;dnaDataSet.getNumberOfElements();i++){&lt;br /&gt;
			System.out.println(dnaDataSet.getElementAt( i ));&lt;br /&gt;
		}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s are printed in their original alphabet since their &amp;lt;code&amp;gt;toString()&amp;lt;/code&amp;gt; method is overridden accordingly.&lt;br /&gt;
&lt;br /&gt;
As an alternative to the iteration by explicit calls to these methods, [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] also implements the &amp;lt;code&amp;gt;Iterable&amp;lt;/code&amp;gt; interface, which facilitates the Java variant&lt;br /&gt;
of foreach-loops as in the following example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		for(Sequence seq : contDataSet){&lt;br /&gt;
			System.out.println(seq.getLength());&lt;br /&gt;
		}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, we just print the length of each [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] in &amp;lt;code&amp;gt;contSample&amp;lt;/code&amp;gt; to standard out.&lt;br /&gt;
&lt;br /&gt;
We can also apply some of the sequence-level operations to all [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s of a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet], and obtain a new [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] containing the modified sequences. For example, we get a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] containing &lt;br /&gt;
the sub-sequences of length &amp;lt;math&amp;gt;10&amp;lt;/math&amp;gt; starting at position &amp;lt;math&amp;gt;3&amp;lt;/math&amp;gt; of each sequence by calling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet infix = dnaDataSet.getInfixDataSet( 3, 10 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] of all suffixes starting at position &amp;lt;math&amp;gt;7&amp;lt;/math&amp;gt; from&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet suffix = dnaDataSet.getSuffixDataSet( 7 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] containing all reverse complementary [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s using&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet allRevComplements = dnaDataSet.getReverseComplementaryDataSet();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For cross-validation experiments, hold-out samplings, or similar procedures (cf. [http://www.jstacs.de/api-2.0/ de/jstacs/classifier/assessment/package-summary.html package assessment]), it is useful to partition a sample randomly. [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] s in Jstacs support two types of partitionings.&lt;br /&gt;
The first is to partition a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] into &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt; almost equally sized parts. What is &amp;amp;quot;equally sized&amp;amp;quot; can either be determined by the number of sequences or by the number of symbols of all sequences in a sample. Both measures are supported by Jstacs. &lt;br /&gt;
&lt;br /&gt;
The second partitioning method creates partitions of a user-defined fraction of the original sample. For example, we partition the [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] &amp;lt;code&amp;gt;dnaSample&amp;lt;/code&amp;gt; into five equally sized parts according to the number of sequences in that [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] by calling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet[] fiveParts = dnaDataSet.partition( 5, PartitionMethod.PARTITION_BY_NUMBER_OF_ELEMENTS );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and we partition the same sample into parts containing &amp;lt;math&amp;gt;10&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;20&amp;lt;/math&amp;gt;, and &amp;lt;math&amp;gt;70&amp;lt;/math&amp;gt; percent of the symbols of the original [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] by calling&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet[] randParts = dnaDataSet.partition( PartitionMethod.PARTITION_BY_NUMBER_OF_SYMBOLS, 0.1, 0.2, 0.7 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In both cases, the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s in the [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] are partitioned as atomic elements. That means, a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] is not cut into several parts to obtain exactly equally sized parts, but the size of a part may slightly (depending on the number of sequences and lengths of those sequences) differ from the specified percentages.&lt;br /&gt;
&lt;br /&gt;
To create a new [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] that contains all sub-sequences of a user-defined length of the original [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] s, we can use another constructor of [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet]. The sub-sequences are extracted in the same manner as we would do by shifting a sliding window over each sequence, extracting the sub-sequence under this window, and build a new [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] of the extracted sub-sequences.&lt;br /&gt;
For instance, we obtain a [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] with all sub-sequences of length &amp;lt;math&amp;gt;8&amp;lt;/math&amp;gt; using&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet sliding = new DataSet( dnaDataSet, 8 );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the previous sub-section, we learned how to add [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SequenceAnnotation.html SequenceAnnotation] s to a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence]. Often, we want to use the annotation that is already present in an input file, for example&lt;br /&gt;
the comment line of a FastA file. We can do so by specifying a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SequenceAnnotationParser.html SequenceAnnotationParser] in the constructor of the [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet]. The simplest type of [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SequenceAnnotationParser.html SequenceAnnotationParser] †is the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SimpleSequenceAnnotationParser.html SimpleSequenceAnnotationParser], which just extracts the complete comment line preceding a sequence.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DNADataSet dnaWithComments = new DNADataSet( &amp;quot;myfile.fa&amp;quot;, &amp;#039;&amp;gt;&amp;#039;, new SimpleSequenceAnnotationParser() );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although the specification of the parser is quite simple, the extraction of the comment line as a string is a bit lengthy. We first obtain the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/Sequence.html Sequence] from the [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet], get the annotation of that sequence, obtain the first comment, called &amp;amp;quot;result&amp;amp;quot; in the hierarchy of Jstacs (you see in section [[#sec:xmlparres (link)]], why), and convert the corresponding result object to a string.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		String comment = dnaWithComments.getElementAt( 0 ).getAnnotation()[0].getResultAt( 0 ).getValue().toString();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If your comment line is defined in a &amp;amp;quot;key-value&amp;amp;quot; format with some generic delimiter between entries, you can Jstacs let parse the entries to distinct annotations. For instance, if the comment line has some format &amp;lt;code&amp;gt;key1=value1; key2=value2;...&amp;lt;/code&amp;gt;, we can parse that comment line using the [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SplitSequenceAnnotationParser.html SplitSequenceAnnotationParser]. This parser only requires the specification of the delimiter between key and value (&amp;amp;quot;=&amp;amp;quot; in the example) and the delimiter between different entries (&amp;amp;quot;;&amp;amp;quot; in the example). Like before, we instantiate a [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SplitSequenceAnnotationParser.html SplitSequenceAnnotationParser] as the last argument of the [http://www.jstacs.de/api-2.0//de/jstacs/data/DNADataSet.html DNADataSet] constructor:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DNADataSet dnaWithParsedComments = new DNADataSet( &amp;quot;myfile.fa&amp;quot;, &amp;#039;&amp;gt;&amp;#039;, new SplitSequenceAnnotationParser(&amp;quot;=&amp;quot;,&amp;quot;;&amp;quot;) );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now access all parsed annotations by the &amp;lt;code&amp;gt;getAnnotation()&amp;lt;/code&amp;gt; method&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		SequenceAnnotation[] allAnnotations2 = dnaWithParsedComments.getElementAt( 0 ).getAnnotation();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or, for instance, the &amp;lt;code&amp;gt;getSequenceAnnotationByType&amp;lt;/code&amp;gt; introduced in the previous section, where the type corresponds to the key in the comment line, and the identifier of the retrieved [http://www.jstacs.de/api-2.0//de/jstacs/data/sequences/annotation/SequenceAnnotation.html SequenceAnnotation] is identical to the value for that key in the comment line.&lt;br /&gt;
&lt;br /&gt;
Jstacs only supports FastA and plain text files directly. However, you can access other formats or even databases like Genbank using an adaptor to BioJava.&lt;br /&gt;
&lt;br /&gt;
For example, we can use BioJava to load two sequences from Genbank.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		GenbankRichSequenceDB db = new GenbankRichSequenceDB();&lt;br /&gt;
		&lt;br /&gt;
		SequenceIterator dbIterator = new SimpleSequenceIterator( &lt;br /&gt;
				db.getRichSequence( &amp;quot;NC_001284&amp;quot; ), &lt;br /&gt;
				db.getRichSequence( &amp;quot;NC_000932&amp;quot; ) &lt;br /&gt;
		);&lt;br /&gt;
		&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As a result, we obtain a &amp;lt;code&amp;gt;RichSequenceIterator&amp;lt;/code&amp;gt;, which implements the &amp;lt;code&amp;gt;SequenceIterator&amp;lt;/code&amp;gt; interface of BioJava. We can use a&lt;br /&gt;
&amp;lt;code&amp;gt;SequenceIterator&amp;lt;/code&amp;gt; in an adaptor method to obtain a Jstacs [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] including converted annotations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		DataSet fromBioJava = BioJavaAdapter.sequenceIteratorToDataSet( dbIterator, null );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The second argument of the method allows for filtering for specific annotations using a BioJava &amp;lt;code&amp;gt;FeatureFilter&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Vice versa, we can convert a Jstacs [http://www.jstacs.de/api-2.0//de/jstacs/data/DataSet.html DataSet] to a BioJava &amp;lt;code&amp;gt;SequenceIterator&amp;lt;/code&amp;gt; by an analogous adaptor method:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java5&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
		SequenceIterator backFromJstacs = BioJavaAdapter.dataSetToSequenceIterator( fromBioJava, true );&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By means of these two methods, we can use all BioJava facilities for loading and storing data from and to diverse file formats and loading data from data bases in our Jstacs applications.&lt;/div&gt;</summary>
		<author><name>Grau</name></author>
	</entry>
</feed>