本文整理汇总了Java中htsjdk.samtools.SAMSequenceDictionary.getSequenceIndex方法的典型用法代码示例。如果您正苦于以下问题:Java SAMSequenceDictionary.getSequenceIndex方法的具体用法?Java SAMSequenceDictionary.getSequenceIndex怎么用?Java SAMSequenceDictionary.getSequenceIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMSequenceDictionary
的用法示例。
在下文中一共展示了SAMSequenceDictionary.getSequenceIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertSimpleIntervalToQueryInterval
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Converts an interval in SimpleInterval format into an htsjdk QueryInterval.
*
* In doing so, a header lookup is performed to convert from contig name to index
*
* @param interval interval to convert
* @param sequenceDictionary sequence dictionary used to perform the conversion
* @return an equivalent interval in QueryInterval format
*/
private static QueryInterval convertSimpleIntervalToQueryInterval( final Interval interval, final SAMSequenceDictionary sequenceDictionary ) {
if (interval == null) {
throw new IllegalArgumentException("interval may not be null");
}
if (sequenceDictionary == null) {
throw new IllegalArgumentException("sequence dictionary may not be null");
}
final int contigIndex = sequenceDictionary.getSequenceIndex(interval.getContig());
if ( contigIndex == -1 ) {
throw new IllegalArgumentException("Contig " + interval.getContig() + " not present in reads sequence " +
"dictionary");
}
return new QueryInterval(contigIndex, interval.getStart(), interval.getEnd());
}
示例2: readCrossContigsToIgnoreFile
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/** Read a file of contig names that will be ignored when checking for inter-contig pairs. */
private static Set<Integer> readCrossContigsToIgnoreFile( final String crossContigsToIgnoreFile,
final SAMSequenceDictionary dictionary ) {
final Set<Integer> ignoreSet = new HashSet<>();
try ( final BufferedReader rdr =
new BufferedReader(
new InputStreamReader(BucketUtils.openFile(crossContigsToIgnoreFile))) ) {
String line;
while ( (line = rdr.readLine()) != null ) {
final int tigId = dictionary.getSequenceIndex(line);
if ( tigId == -1 ) {
throw new UserException("crossContigToIgnoreFile contains an unrecognized contig name: "+line);
}
ignoreSet.add(tigId);
}
}
catch ( final IOException ioe ) {
throw new UserException("Can't read crossContigToIgnore file "+crossContigsToIgnoreFile, ioe);
}
return ignoreSet;
}
示例3: compareContigs
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public static int compareContigs(final GenomeLocation first, final GenomeLocation second, final SAMSequenceDictionary dictionary) {
Utils.nonNull(first);
Utils.nonNull(second);
Utils.nonNull(dictionary);
final int firstRefIndex = dictionary.getSequenceIndex(first.getContig());
final int secondRefIndex = dictionary.getSequenceIndex(second.getContig());
if (firstRefIndex == -1 || secondRefIndex == -1) {
throw new IllegalArgumentException("Can't do comparison because Locatables' contigs not found in sequence dictionary");
}
// compare the contigs
return Integer.compare(firstRefIndex, secondRefIndex);
}
示例4: parseLocationString
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
static Location parseLocationString(final String location, final SAMSequenceDictionary dictionary) throws RuntimeException {
final Location result = new Location();
final String[] split = location.split(":");
if (split.length != 2) {
throw new RuntimeException(location + " is not a valid location string");
}
final String chromosome = split[0];
result.ReferenceName = chromosome;
try {
result.Position = Integer.parseInt(split[1]);
} catch (NumberFormatException e) {
throw new RuntimeException(location + " is not a valid location string");
}
// query the position
result.ReferenceIndex = dictionary.getSequenceIndex(chromosome);
if (result.ReferenceIndex < 0) {
if (!chromosome.startsWith("chr")) {
result.ReferenceIndex = dictionary.getSequenceIndex("chr" + chromosome);
} else {
result.ReferenceIndex = dictionary.getSequenceIndex(chromosome.substring(3));
}
}
if (result.ReferenceIndex < 0) {
throw new RuntimeException(chromosome + " is not in the BAM");
}
return result;
}
示例5: compareLoci
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public int compareLoci(ReadsAtLocus that, SAMSequenceDictionary dict) {
int compare = dict.getSequenceIndex(this.getChromosome()) - dict.getSequenceIndex(that.getChromosome());
if (compare == 0) {
compare = this.getPosition() - that.getPosition();
}
return compare;
}
示例6: toRightOf
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* @return <code>true</code> if the locatable is to the right of the given interval
*/
private static <I extends Locatable, L extends Locatable> boolean toRightOf(I interval, L locatable, SAMSequenceDictionary sequenceDictionary) {
int intervalContigIndex = sequenceDictionary.getSequenceIndex(interval.getContig());
int locatableContigIndex = sequenceDictionary.getSequenceIndex(locatable.getContig());
return (intervalContigIndex == locatableContigIndex && interval.getEnd() < locatable.getStart()) // locatable on same contig, to the right
|| intervalContigIndex < locatableContigIndex; // locatable on subsequent contig
}
示例7: compareContigs
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Determines the relative contig ordering of first and second using the provided sequence dictionary
*
* @param first first Locatable
* @param second second Locatable
* @param dictionary sequence dictionary used to determine contig ordering
* @return 0 if the two contigs are the same, a negative value if first's contig comes before second's contig,
* or a positive value if first's contig comes after second's contig
*/
public static int compareContigs(final Locatable first, final Locatable second, final SAMSequenceDictionary dictionary) {
Utils.nonNull(first);
Utils.nonNull(second);
Utils.nonNull(dictionary);
final int firstRefIndex = dictionary.getSequenceIndex(first.getContig());
final int secondRefIndex = dictionary.getSequenceIndex(second.getContig());
if (firstRefIndex == -1 || secondRefIndex == -1) {
throw new IllegalArgumentException("Can't do comparison because Locatables' contigs not found in sequence dictionary");
}
// compare the contigs
return Integer.compare(firstRefIndex, secondRefIndex);
}
示例8: convertSimpleIntervalToQueryInterval
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Converts an interval in SimpleInterval format into an htsjdk QueryInterval.
*
* In doing so, a header lookup is performed to convert from contig name to index
*
* @param interval interval to convert
* @param sequenceDictionary sequence dictionary used to perform the conversion
* @return an equivalent interval in QueryInterval format
*/
public static QueryInterval convertSimpleIntervalToQueryInterval( final SimpleInterval interval, final SAMSequenceDictionary sequenceDictionary ) {
Utils.nonNull(interval);
Utils.nonNull(sequenceDictionary);
final int contigIndex = sequenceDictionary.getSequenceIndex(interval.getContig());
if ( contigIndex == -1 ) {
throw new UserException("Contig " + interval.getContig() + " not present in reads sequence dictionary");
}
return new QueryInterval(contigIndex, interval.getStart(), interval.getEnd());
}
示例9: readBreakpointsFromTruthVCF
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public static SVIntervalTree<String> readBreakpointsFromTruthVCF(final String truthVCF,
final SAMSequenceDictionary dictionary,
final int padding ) {
SVIntervalTree<String> breakpoints = new SVIntervalTree<>();
try ( final FeatureDataSource<VariantContext> dataSource =
new FeatureDataSource<>(truthVCF, null, 0, VariantContext.class) ) {
for ( final VariantContext vc : dataSource ) {
final StructuralVariantType svType = vc.getStructuralVariantType();
if ( svType == null ) continue;
final String eventName = vc.getID();
final int contigID = dictionary.getSequenceIndex(vc.getContig());
if ( contigID < 0 ) {
throw new UserException("VCF contig " + vc.getContig() + " does not appear in dictionary.");
}
final int start = vc.getStart();
switch ( svType ) {
case DEL:
case INV:
case CNV:
final int end = vc.getEnd();
breakpoints.put(new SVInterval(contigID,start-padding, end+padding), eventName);
break;
case INS:
case DUP:
case BND:
breakpoints.put(new SVInterval(contigID,start-padding, start+padding), eventName);
break;
}
}
}
return breakpoints;
}
示例10: parseSJString
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public void parseSJString(String sjString, SAMSequenceDictionary dict) {
String columns[] = sjString.split("\t");
this.type = -1;
this.secondary_key = dict.getSequenceIndex(columns[0]);
}