Package htsjdk.samtools
Class SAMSequenceDictionary
java.lang.Object
htsjdk.samtools.SAMSequenceDictionary
- All Implemented Interfaces:
HtsHeader
,Serializable
Collection of SAMSequenceRecords.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAlternativeSequenceName
(String originalName, String altName) Add an alternative sequence name (AN tag) to a SAMSequenceRecord, including it into the aliases to retrieve the contigs (as withaddSequenceAlias(String, String)
.void
addSequence
(SAMSequenceRecord sequenceRecord) addSequenceAlias
(String originalName, String altName) Add an alias to a SAMSequenceRecord.void
Non-comprehensiveequals(Object)
-assertion: instead of callingSAMSequenceRecord.equals(Object)
on constituentSAMSequenceRecord
s in this dictionary against its pair in the target dictionary, in order, callSAMSequenceRecord.isSameSequence(SAMSequenceRecord)
.boolean
Returnstrue
if the two dictionaries are the same.long
getSequence
(int sequenceIndex) getSequence
(String name) int
getSequenceIndex
(String sequenceName) int
hashCode()
boolean
isEmpty()
boolean
Non-comprehensiveequals(Object)
-validation: instead of callingSAMSequenceRecord.equals(Object)
on constituentSAMSequenceRecord
s in this dictionary against its pair in the target dictionary, in order, callSAMSequenceRecord.isSameSequence(SAMSequenceRecord)
.md5()
return a MD5 sum for ths dictionary, the checksum is re-computed each time this method is called.static SAMSequenceDictionary
mergeDictionaries
(SAMSequenceDictionary dict1, SAMSequenceDictionary dict2, List<String> tagsToMatch) Will merge dictionaryTags from two dictionaries into one focusing on merging the tags rather than the sequences.void
setSequences
(List<SAMSequenceRecord> list) Replaces the existing list of SAMSequenceRecords with the given list.int
size()
toString()
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
DEFAULT_DICTIONARY_EQUAL_TAG
-
-
Constructor Details
-
SAMSequenceDictionary
public SAMSequenceDictionary() -
SAMSequenceDictionary
-
-
Method Details
-
getSequences
-
getSequence
-
setSequences
Replaces the existing list of SAMSequenceRecords with the given list. Reset the aliases- Parameters:
list
- This value is copied and validated.
-
addSequence
-
getSequence
- Returns:
- The SAMSequenceRecord with the given index, or null if index is out of range.
-
getSequenceIndex
- Returns:
- The index for the given sequence name, or -1 if the name is not found.
-
size
public int size()- Returns:
- number of SAMSequenceRecord(s) in this dictionary
-
getReferenceLength
public long getReferenceLength()- Returns:
- The sum of the lengths of the sequences in this dictionary
-
isEmpty
public boolean isEmpty()- Returns:
- true is the dictionary is empty
-
assertSameDictionary
Non-comprehensiveequals(Object)
-assertion: instead of callingSAMSequenceRecord.equals(Object)
on constituentSAMSequenceRecord
s in this dictionary against its pair in the target dictionary, in order, callSAMSequenceRecord.isSameSequence(SAMSequenceRecord)
. Aliases are ignored.- Throws:
AssertionError
- When the dictionaries are not the same, with some human-readable information as to why
-
isSameDictionary
Non-comprehensiveequals(Object)
-validation: instead of callingSAMSequenceRecord.equals(Object)
on constituentSAMSequenceRecord
s in this dictionary against its pair in the target dictionary, in order, callSAMSequenceRecord.isSameSequence(SAMSequenceRecord)
.- Parameters:
that
-SAMSequenceDictionary
to compare against- Returns:
- true if the dictionaries are the same, false otherwise
-
equals
Returnstrue
if the two dictionaries are the same.NOTE: Aliases are NOT considered, but alternative sequence names (AN tag) names ARE.
-
addSequenceAlias
Add an alias to a SAMSequenceRecord. This can be use to provide some alternate names fo a given contig. e.g:1,chr1,chr01,01,CM000663,NC_000001.10
e.g:MT,chrM
NOTE: this method does not add the alias to the alternative sequence name tag (AN) in the SAMSequenceRecord. If you would like to add it to the AN tag, use
addAlternativeSequenceName(String, String)
instead.- Parameters:
originalName
- existing contig namealtName
- new contig name- Returns:
- the contig associated to the 'originalName/altName'
-
addAlternativeSequenceName
Add an alternative sequence name (AN tag) to a SAMSequenceRecord, including it into the aliases to retrieve the contigs (as withaddSequenceAlias(String, String)
.This can be use to provide some alternate names fo a given contig. e.g:
1,chr1,chr01,01,CM000663
orMT,chrM
.- Parameters:
originalName
- existing contig namealtName
- new contig name- Returns:
- the contig associated to the 'originalName/altName', with the AN tag including the altName
-
md5
return a MD5 sum for ths dictionary, the checksum is re-computed each time this method is called.md5( (seq1.md5_if_available) + ' '+(seq2.name+seq2.length) + ' '+...)
- Returns:
- a MD5 checksum for this dictionary or the empty string if it is empty
-
hashCode
public int hashCode() -
toString
-
mergeDictionaries
public static SAMSequenceDictionary mergeDictionaries(SAMSequenceDictionary dict1, SAMSequenceDictionary dict2, List<String> tagsToMatch) Will merge dictionaryTags from two dictionaries into one focusing on merging the tags rather than the sequences. Requires that dictionaries have the same SAMSequence records in the same order. For each sequenceIndex, the union of the tags from both sequences will be added to the new sequence, mismatching values (for tags that are in both) will generate a warning, and the value from dict1 will be used. For tags that are in tagsToEquate an unequal value will generate an error (an IllegalArgumentException will be thrown.) tagsToEquate must include LN and MD.- Parameters:
dict1
- first dictionarydict2
- first dictionarytagsToMatch
- list of tags that must be equal if present in both sequence. Must contain MD, and LN- Returns:
- dictionary consisting of the same sequences as the two inputs with the merged values of tags.
-