public class Dataset
extends javax.swing.AbstractListModel
The internal document format for BioLegato.
This document is structured as a linked list of sequences. Each character has an offset based on its position within the list and it's position within its containing sequence. Sequences start at 0 (first character in the first sequence in the list, and ens with the last character in the last sequence within the list.
Constructor and Description |
---|
Dataset(SequenceCanvas canvas)
Creates a new instance of the Dataset object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(int y,
Seq seq)
Adds a sequence to the Dataset sequence object container.
|
boolean |
addSequences(int y,
java.util.Collection<Seq> seqs)
Adds sequences to the Dataset sequence object container.
|
boolean |
delete(int x,
int y,
int length,
boolean protect)
Deletes a portion of a sequence from the Dataset sequence object
container.
|
java.lang.Object |
getElementAt(int index)
Returns the names of sequences based on their Y-coordinate/"line number".
|
int[] |
getgroup(int lineNumber)
Obtains all of the line numbers of the sequences in a particular group.
|
ColourMask |
getMask(int number)
Retrieves the colour mask object for a given sequence 'line' in the
Dataset sequence object container.
|
int |
getSequence(char[] array,
int number,
int offset,
int length)
Retrieves the text contained within a sequence object in the Dataset.
|
int |
getSequenceLength(int number)
Retrieves the length (in characters) of a given sequence 'line' in the
Dataset sequence object container.
|
int |
getSize()
Returns a count of the total number of sequences (lines) in the Dataset
sequence object container.
|
void |
group(int[] sequences)
Creates a new sequence-group comprised of the sequences specified by
Y-coordinate/"line numbers" in the array parameter 'sequences'.
|
boolean |
insert(int x,
int y,
char[] text,
int offset,
int length,
boolean protect)
Inserts text into the Dataset sequence object container.
|
static boolean |
isProtectionsOn(Seq.Type type,
boolean protect_align,
boolean protect_ambig,
boolean protect_uambig,
char[] test,
int start,
int end)
Checks a string against all of a sequence's protection settings.
|
void |
removeSequences(int[] indices)
Removes multiple sequences from the Dataset sequence object container.
|
void |
ungroup(int[] sequences)
Ungroups an array of sequences by iteratively calling the single-sequence
ungroup function for each sequence number in the array.
|
public Dataset(SequenceCanvas canvas)
canvas
- the parent sequence canvas to associate with the Dataset
object with.public boolean add(int y, Seq seq)
y
- the line index number to insert the sequence object at.seq
- the sequence object to insert.public boolean insert(int x, int y, char[] text, int offset, int length, boolean protect)
Inserts text into the Dataset sequence object container. This function also calls calls all of the listeners which are listening to the Dataset object. Mostly (ane even 'completely', at the time of this writing), listeners are used for displaying the data in the sequence list and the sequence text area. Note that the add method inserts a sequence object, as a whole, into the Dataset, while the insert method inserts the text of a sequence object into the middle of the already present sequence object in the Dataset.
This function also obeys all sequence permissions/protections (as long as the protect boolean is set to true). In the case of text insertion, text may NOT be inserted if it contains a protected character. For example, if the sequence is a protein sequence and the unambiguous character protections are set to true, then the text "BZAZ" may not be inserted because it contains one unambiguous character (A, for alanine); however, the text "BZZZ" may be inserted, as long as the ambiguous character protections are set to false. See Dataset.isProtectionsOn for more information about character protections.
x
- the X-coordinate to insert the sequence text.y
- the Y-coordinate to insert the sequence text.text
- the sequence text to insert.offset
- the offset within the array to insert.length
- the length in characters of data from the array to insert.protect
- whether to test the protections of the sequence, already
in the Dataset, before inserting the text.public boolean delete(int x, int y, int length, boolean protect)
Deletes a portion of a sequence from the Dataset sequence object container. This function also calls calls all of the listeners which are listening to the Dataset object. Mostly (ane even 'completely', at the time of this writing), listeners are used for displaying the data in the sequence list and the sequence text area. Note that the add method deletes a sequence object, as a whole, into the Dataset, while the delete method deletes the text of a sequence object into the middle of the already present sequence object in the Dataset.
This function also obeys all sequence permissions/protections (as long as the protect boolean is set to true). In the case of text deletion, text may NOT be deleted if it contains a protected character. For example, if the sequence is a protein sequence and the unambiguous character protections are set to true, then the text "BZAZ" may not be deleted because it contains one unambiguous character (A, for alanine); however, the text "BZZZ" may be deleted, as long as the ambiguous character protections are set to false.
x
- the X-coordinate to begin the the sequence text deletion.y
- the Y-coordinate to begin the the sequence text deletion.length
- is the length (number of characters) of text to delete.protect
- whether to test the protections of the sequence, already
in the Dataset, before deleting the text.public boolean addSequences(int y, java.util.Collection<Seq> seqs)
y
- the line index number to insert the sequences object at.seqs
- the collection of sequence objects to insert.public void removeSequences(int[] indices)
indices
- an array of line numbers to remove.public int getSize()
public int getSequenceLength(int number)
number
- the y coordinate to retrieve the sequence.public ColourMask getMask(int number)
number
- the line number to retrieve the colour mask for.SequenceCanvas.DEFAULT_MASK
public int getSequence(char[] array, int number, int offset, int length)
Retrieves the text contained within a sequence object in the Dataset. The sequence object to extract text from is specified by its Y-coordinate. The offset and number of characters to extract from the sequence are specified by 'offset' and 'length'. The destination for the text extracted is the character array 'array'. If the Y-coordinate or offset values are invalid, no data is extracted. Invalid Y-coordinates are values which exceed the total number of sequences in the Dataset, or values less than zero. Invalid offsets are those which exceed the number of characters on the sequence "line", or offset values less than zero.
In contrast, if the length value exceeds the number of characters in the sequence, the sequence's length is used instead. Thus, the length parameter may be slightly invalid (it may exceed the sequence length, but NOT be less than zero).
array
- the destination for the characters to be copied to.number
- the sequence "line number"/Y-coordinate to extract data.offset
- the offset within the sequence to begin copying data from.length
- the number of characters to attempt to copy.public void group(int[] sequences)
sequences
- the array of Y-coordinates corresponding to sequences
to include in the new group.public void ungroup(int[] sequences)
sequences
- the array of Y-coordinates/"line numbers", which
correspond to the sequences to ungroup.public int[] getgroup(int lineNumber)
lineNumber
- the Y-coordinate/"line number" of the sequence to
use as a reference for determining the group number.public java.lang.Object getElementAt(int index)
index
- the Y-coordinate of the sequence to obtain.Seq.toString()
public static boolean isProtectionsOn(Seq.Type type, boolean protect_align, boolean protect_ambig, boolean protect_uambig, char[] test, int start, int end)
Checks a string against all of a sequence's protection settings. A string of text is said to violate the protection settings (for deletion or insertion purposes) if the text contains any characters which are protected. Whether a character is protected is determined by the Seq object's protection status settings. These protection status settings are split into three variables (for 3 classes of characters):
If a character from any of the three classes is matched in the text passed to this function, and the character matched has its protection status is true, the text is barred from insertion or deletion. In contrast, any character matched in the text with its character protection status set to false is ignored. Thus text containing all characters which have false protection statuses may be inserted or deleted. A couple of examples will help demonstrate this:
Please note that ON/OFF are interchangeable in this document with the terms TRUE/FALSE, where ON is TRUE, and OFF is FALSE.
Please also note that only DNA, RNA and PROTEIN sequences have protection settings, thus any non DNA, RNA, or PROTEIN sequence type tested will always return false, regardless of the text. An example of a non-RNA/DNA/PROTEIN sequence is Seq.Type.TEXT.
type
- the type of the sequence to test.protect_align
- the protection status of alignment characters.protect_ambig
- the protection status of ambiguous characters.protect_uambig
- the protection status of unambiguous characters.test
- the sequence text to test.start
- the index within 'text' to start the test.end
- the index within 'text' to end the test.Seq.protect_align
,
Seq.protect_ambig
,
Seq.protect_unambig
,
Seq.Type.DNA
,
Seq.Type.RNA
,
Seq.Type.PROTEIN
,
Seq.Type.MASK
,
Seq.Type.TEXT
,
insert(int, int, char[], int, int, boolean)
,
delete(int, int, int, boolean)
Copyright © 2008-2022 University of Manitoba.