本文整理汇总了Java中htsjdk.samtools.SAMSequenceDictionary.size方法的典型用法代码示例。如果您正苦于以下问题:Java SAMSequenceDictionary.size方法的具体用法?Java SAMSequenceDictionary.size怎么用?Java SAMSequenceDictionary.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMSequenceDictionary
的用法示例。
在下文中一共展示了SAMSequenceDictionary.size方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MRUCachingSAMSequenceDictionary
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Create a new MRUCachingSAMSequenceDictionary that provides information about sequences in dict
*
* @param dict a non-null, non-empty sequencing dictionary
*/
public MRUCachingSAMSequenceDictionary(final SAMSequenceDictionary dict) {
if (dict == null) throw new IllegalArgumentException("Dictionary cannot be null");
if (dict.size() == 0)
throw new IllegalArgumentException("Dictionary cannot have size zero");
this.dict = dict;
}
示例2: prettyPrintSequenceRecords
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public static String prettyPrintSequenceRecords ( SAMSequenceDictionary sequenceDictionary ) {
String[] sequenceRecordNames = new String[sequenceDictionary.size()];
int sequenceRecordIndex = 0;
for (SAMSequenceRecord sequenceRecord : sequenceDictionary.getSequences())
sequenceRecordNames[sequenceRecordIndex++] = sequenceRecord.getSequenceName();
return Arrays.deepToString(sequenceRecordNames);
}
示例3: correctCoordsAgainstSeqDict
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public void correctCoordsAgainstSeqDict(SAMSequenceDictionary samSeqDict) throws InvalidGenomicCoordsException, IOException{
if(samSeqDict == null || samSeqDict.size() == 0){
// Just check start pos
if (this.from <=0 ){
this.from= 1;
}
return;
}
if(this.chrom == null){ // Nothing to do
return;
}
if(samSeqDict.getSequence(this.chrom) == null){ // Not found: Nullify everything
this.chrom= null;
this.from= null;
this.to= null;
return;
}
// Reset min coords
if( this.from != null && this.from < 1) {
this.from= 1;
}
// Reset max coords
if( this.from != null && this.from > samSeqDict.getSequence(this.chrom).getSequenceLength() ) {
this.from= samSeqDict.getSequence(this.chrom).getSequenceLength() - this.getGenomicWindowSize() + 1;
if(this.from <= 0){
this.from= 1;
}
this.to= this.from + this.getGenomicWindowSize() - 1;
if(this.to > samSeqDict.getSequence(this.chrom).getSequenceLength()){
this.to= samSeqDict.getSequence(this.chrom).getSequenceLength();
}
}
if( this.to != null && this.to > samSeqDict.getSequence(this.chrom).getSequenceLength() ) {
this.to= samSeqDict.getSequence(this.chrom).getSequenceLength();
}
}
示例4: compareDictionaries
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Workhorse routine that takes two dictionaries and returns their compatibility.
*
* @param dict1 first sequence dictionary
* @param dict2 second sequence dictionary
* @param checkContigOrdering if true, perform checks related to contig ordering: forbid lexicographically-sorted
* dictionaries, and require common contigs to be in the same relative order and at the
* same absolute indices
* @return A SequenceDictionaryCompatibility enum value describing the compatibility of the two dictionaries
*/
public static SequenceDictionaryCompatibility compareDictionaries( final SAMSequenceDictionary dict1, final SAMSequenceDictionary dict2, final boolean checkContigOrdering ) {
if ( checkContigOrdering && (nonCanonicalHumanContigOrder(dict1) || nonCanonicalHumanContigOrder(dict2)) ) {
return SequenceDictionaryCompatibility.NON_CANONICAL_HUMAN_ORDER;
}
final Set<String> commonContigs = getCommonContigsByName(dict1, dict2);
if (commonContigs.isEmpty()) {
return SequenceDictionaryCompatibility.NO_COMMON_CONTIGS;
}
else if ( ! commonContigsHaveSameLengths(commonContigs, dict1, dict2) ) {
return SequenceDictionaryCompatibility.UNEQUAL_COMMON_CONTIGS;
}
final boolean commonContigsAreInSameRelativeOrder = commonContigsAreInSameRelativeOrder(commonContigs, dict1, dict2);
if ( checkContigOrdering && ! commonContigsAreInSameRelativeOrder ) {
return SequenceDictionaryCompatibility.OUT_OF_ORDER;
}
else if ( commonContigsAreInSameRelativeOrder && commonContigs.size() == dict1.size() && commonContigs.size() == dict2.size() ) {
return SequenceDictionaryCompatibility.IDENTICAL;
}
else if ( checkContigOrdering && ! commonContigsAreAtSameIndices(commonContigs, dict1, dict2) ) {
return SequenceDictionaryCompatibility.DIFFERENT_INDICES;
}
else if ( supersets(dict1, dict2) ) {
return SequenceDictionaryCompatibility.SUPERSET;
}
else {
return SequenceDictionaryCompatibility.COMMON_SUBSET;
}
}
示例5: prettyPrintSequenceRecords
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public static String prettyPrintSequenceRecords( final SAMSequenceDictionary sequenceDictionary ) {
final String[] sequenceRecordNames = new String[sequenceDictionary.size()];
int sequenceRecordIndex = 0;
for (final SAMSequenceRecord sequenceRecord : sequenceDictionary.getSequences()) {
sequenceRecordNames[sequenceRecordIndex++] = sequenceRecord.getSequenceName();
}
return Arrays.deepToString(sequenceRecordNames);
}
示例6: getChromosomeNames
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
private String[] getChromosomeNames(SAMSequenceDictionary dict) {
String[] chrs = new String[dict.size()];
for(int i = 0; i < dict.size(); i++)
chrs[i] = dict.getSequence(i).getSequenceName();
return chrs;
}
示例7: getReferenceSequenceDictionaryFromMap
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Given a reference map, get a SAMSequenceDictionary that lists its contigs and their length.
* Note that this does NOT use the referenceContig order from the API. Instead, we'll sort them
* and try to match the read sequence dictionary order, if given.
*
* @param referenceMap - return value from getReferenceNameToReferenceTable
* @param optReadSequenceDictionaryToMatch - (optional) the sequence dictionary of the reads, we'll match its order if possible.
* @return a SAMSequenceDictionary that lists the referenceset's contigs and their length.
*/
public SAMSequenceDictionary getReferenceSequenceDictionaryFromMap(final Map<String, Reference> referenceMap, final SAMSequenceDictionary optReadSequenceDictionaryToMatch) {
SAMSequenceDictionary refDictionary = new SAMSequenceDictionary();
ArrayList<SAMSequenceRecord> refContigs = new ArrayList<>();
for (Map.Entry<String, Reference> e : referenceMap.entrySet()) {
if (e.getKey()!=null && e.getValue().getLength()!=null) {
refContigs.add(new SAMSequenceRecord(e.getKey(), e.getValue().getLength().intValue()));
}
}
HashMap<String,Integer> indexBuilder = null;
if (null!=optReadSequenceDictionaryToMatch) {
indexBuilder = new LinkedHashMap<>();
for (int i=0; i<optReadSequenceDictionaryToMatch.size(); i++) {
final SAMSequenceRecord sequence = optReadSequenceDictionaryToMatch.getSequence(i);
indexBuilder.put(sequence.getSequenceName(), i);
}
}
final Map<String,Integer> optReadSequenceDictionaryToMatchIndex = indexBuilder;
// GATK requires human contigs in karyotypic order: 1, 2, ..., 10, 11, ..., 20, 21, 22, X, Y with M either leading or trailing these contigs.
// So we sort them.
Collections.sort(refContigs, new Comparator<SAMSequenceRecord>() {
@Override
public int compare(SAMSequenceRecord o1, SAMSequenceRecord o2) {
// if those are ordered in the readDictionary, then match that order
if (null != optReadSequenceDictionaryToMatchIndex) {
if (optReadSequenceDictionaryToMatchIndex.containsKey(o1.getSequenceName()) && optReadSequenceDictionaryToMatchIndex.containsKey(o2.getSequenceName())) {
return optReadSequenceDictionaryToMatchIndex.get(o1.getSequenceName()).compareTo(optReadSequenceDictionaryToMatchIndex.get(o2.getSequenceName()));
}
}
// otherwise, order them in karyotypic order.
int r1 = getRank(o1.getSequenceName());
int r2 = getRank(o2.getSequenceName());
if (r1 < r2) return -1;
if (r2 < r1) return 1;
return o1.getSequenceName().compareTo(o2.getSequenceName());
}
private int getRank(String name) {
if (name.equalsIgnoreCase("x")) return 23;
if (name.equalsIgnoreCase("y")) return 24;
if (name.equalsIgnoreCase("m")) return 25;
if (name.equalsIgnoreCase("mt")) return 25;
StringBuilder b = new StringBuilder();
for (char c : name.toCharArray()) {
if (Character.isDigit(c)) {
b.append(c);
}
}
String numsOnly = b.toString();
if (numsOnly.isEmpty()) return 0;
return Integer.parseInt(numsOnly);
}
});
for (SAMSequenceRecord s : refContigs) {
refDictionary.addSequence(s);
}
return refDictionary;
}