本文整理汇总了Java中htsjdk.samtools.SAMSequenceDictionary.addSequence方法的典型用法代码示例。如果您正苦于以下问题:Java SAMSequenceDictionary.addSequence方法的具体用法?Java SAMSequenceDictionary.addSequence怎么用?Java SAMSequenceDictionary.addSequence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.SAMSequenceDictionary
的用法示例。
在下文中一共展示了SAMSequenceDictionary.addSequence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: haplotypeMapForWriting
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@DataProvider(name="haplotypeMapForWriting")
public Object[][] haplotypeMapForWriting() {
SAMFileHeader header = new SAMFileHeader();
header.setSortOrder(SAMFileHeader.SortOrder.coordinate);
SAMSequenceDictionary sd = new SAMSequenceDictionary();
sd.addSequence(new SAMSequenceRecord("chr1", 101));
sd.addSequence(new SAMSequenceRecord("chr2", 101));
sd.addSequence(new SAMSequenceRecord("chr3", 101));
header.setSequenceDictionary(sd);
HaplotypeMap newMap = new HaplotypeMap(header);
HaplotypeBlock t1 = new HaplotypeBlock(0.151560926);
t1.addSnp(new Snp("snp2", "chr1", 83, (byte)'A', (byte)'G', .16, null));
t1.addSnp(new Snp("snp1", "chr1", 51, (byte)'T', (byte)'C', 0.15, Collections.singletonList("SQNM_1CHIP_FingerprintAssays")));
newMap.addHaplotype(t1);
HaplotypeBlock t2 = new HaplotypeBlock(.02d);
t2.addSnp(new Snp("snp3", "chr2", 24, (byte)'C', (byte)'A', .20, null));
newMap.addHaplotype(t2);
return new Object[][]{{newMap}};
}
示例2: testCompareLocatables
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testCompareLocatables() throws Exception {
final SAMSequenceDictionary dict = new SAMSequenceDictionary();
dict.addSequence(new SAMSequenceRecord("1", 1000));
dict.addSequence(new SAMSequenceRecord("2", 1000));
final SimpleInterval chr1_1_100 = new SimpleInterval("1:1-100");
final SimpleInterval chr1_5_100 = new SimpleInterval("1:5-100");
final SimpleInterval chr2_1_100 = new SimpleInterval("2:1-100");
// equal intervals comparison return 0
Assert.assertEquals(IntervalUtils.compareLocatables(chr1_1_100, chr1_1_100, dict), 0);
Assert.assertEquals(IntervalUtils.compareLocatables(chr1_5_100, chr1_5_100, dict), 0);
Assert.assertEquals(IntervalUtils.compareLocatables(chr2_1_100, chr2_1_100, dict), 0);
// first < second return negative
Assert.assertTrue(IntervalUtils.compareLocatables(chr1_1_100, chr1_5_100, dict) < 0);
Assert.assertTrue(IntervalUtils.compareLocatables(chr1_1_100, chr2_1_100, dict) < 0);
Assert.assertTrue(IntervalUtils.compareLocatables(chr1_5_100, chr2_1_100, dict) < 0);
// first > second return positive
Assert.assertTrue(IntervalUtils.compareLocatables(chr2_1_100, chr1_1_100, dict) > 0);
Assert.assertTrue(IntervalUtils.compareLocatables(chr2_1_100, chr1_5_100, dict) > 0);
Assert.assertTrue(IntervalUtils.compareLocatables(chr1_5_100, chr1_1_100, dict) > 0);
}
示例3: testLocatableOrderingData
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@DataProvider
public Object[][] testLocatableOrderingData() {
final SAMSequenceDictionary dict = new SAMSequenceDictionary();
dict.addSequence(new SAMSequenceRecord("1", 1000));
dict.addSequence(new SAMSequenceRecord("2", 1000));
return new Object[][] {
// first, second, dictionary, expectedIsBefore, expectedIsAfter, expectedContigComparison
{ new SimpleInterval("1", 1, 100), new SimpleInterval("1", 200, 300), dict, true, false, 0 },
{ new SimpleInterval("1", 1, 100), new SimpleInterval("1", 101, 200), dict, true, false, 0 },
{ new SimpleInterval("1", 1, 100), new SimpleInterval("1", 100, 200), dict, false, false, 0 },
{ new SimpleInterval("1", 1, 100), new SimpleInterval("1", 99, 200), dict, false, false, 0 },
{ new SimpleInterval("1", 200, 300), new SimpleInterval("1", 1, 100), dict, false, true, 0 },
{ new SimpleInterval("1", 101, 200), new SimpleInterval("1", 1, 100), dict, false, true, 0 },
{ new SimpleInterval("1", 100, 200), new SimpleInterval("1", 1, 100), dict, false, false, 0 },
{ new SimpleInterval("1", 99, 200), new SimpleInterval("1", 1, 100), dict, false, false, 0 },
{ new SimpleInterval("1", 1, 100), new SimpleInterval("2", 1, 100), dict, true, false, -1 },
{ new SimpleInterval("1", 1, 100), new SimpleInterval("2", 101, 200), dict, true, false, -1 },
{ new SimpleInterval("1", 101, 200), new SimpleInterval("2", 1, 100), dict, true, false, -1 },
{ new SimpleInterval("2", 1, 100), new SimpleInterval("1", 1, 100), dict, false, true, 1 },
{ new SimpleInterval("2", 101, 200), new SimpleInterval("1", 1, 100), dict, false, true, 1 },
{ new SimpleInterval("2", 1, 100), new SimpleInterval("1", 101, 200), dict, false, true, 1 }
};
}
示例4: testMalformedAmbiguousQuerySucceeds
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testMalformedAmbiguousQuerySucceeds() {
final SAMSequenceDictionary sd = getAmbiguousSequenceDictionary();
final String queryString = "contig:abc-dce";
sd.addSequence(new SAMSequenceRecord("contig", 99));
sd.addSequence(new SAMSequenceRecord(queryString, 99));
// the query string matches as a full contig, but also has a prefix that matches the contig "contig". When
// viewed as the latter, however, the start-end positions fail to parse as numbers. This resolves as a query
// against the longer contig "contig:abc-dce", and logs a warning
HashSet<SimpleInterval> expectedIntervals = new HashSet<>();
expectedIntervals.add(new SimpleInterval(queryString, 1, 99));
Assert.assertEquals(
new HashSet<>(IntervalUtils.getResolvedIntervals(queryString, sd)),
new HashSet<>(expectedIntervals));
}
示例5: testTerminatingPlusSign
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testTerminatingPlusSign() {
// special case test for a query "prefix:+", where "prefix:" is a valid contig
final SAMSequenceDictionary sd = getAmbiguousSequenceDictionary();
final String contigPrefix = "prefix:";
sd.addSequence(new SAMSequenceRecord(contigPrefix, 99));
Assert.assertEquals(
new HashSet<>(IntervalUtils.getResolvedIntervals(contigPrefix + "+", sd)),
new HashSet<>());
sd.addSequence(new SAMSequenceRecord(contigPrefix + "+", 99));
HashSet<SimpleInterval> expectedIntervals = new HashSet<>();
expectedIntervals.add(new SimpleInterval("prefix:+", 1, 99));
Assert.assertEquals(
new HashSet<>(IntervalUtils.getResolvedIntervals(contigPrefix + "+", sd)),
expectedIntervals);
}
示例6: testContigHasColon
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testContigHasColon() {
SAMFileHeader header = new SAMFileHeader();
header.setSortOrder(htsjdk.samtools.SAMFileHeader.SortOrder.coordinate);
SAMSequenceDictionary dict = new SAMSequenceDictionary();
SAMSequenceRecord rec = new SAMSequenceRecord("c:h:r1", 10);
rec.setSequenceLength(10);
dict.addSequence(rec);
header.setSequenceDictionary(dict);
final GenomeLocParser myGenomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
GenomeLoc loc = myGenomeLocParser.parseGenomeLoc("c:h:r1:4-5");
assertEquals(0, loc.getContigIndex());
assertEquals(loc.getStart(), 4);
assertEquals(loc.getStop(), 5);
}
示例7: testDoSetPairFlags
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test(groups = "spark")
public void testDoSetPairFlags() {
final JavaSparkContext ctx = SparkContextFactory.getTestSparkContext();
final SAMSequenceDictionary seq = new SAMSequenceDictionary();
seq.addSequence(new SAMSequenceRecord("test_seq", 1000));
final SAMFileHeader header = new SAMFileHeader(seq);
final List<GATKRead> readList = makeReadSet(header);
final JavaRDD<GATKRead> reads = ctx.parallelize(readList);
;
final List<GATKRead> result = PSFilter.setPairFlags(reads, 100).collect();
Assert.assertEquals(result.size(), 6);
for (final GATKRead read : result) {
if (read.getName().equals("paired_1") || read.getName().equals("paired_2")) {
Assert.assertTrue(read.isPaired());
} else {
Assert.assertFalse(read.isPaired());
}
}
}
示例8: createArtificialSamHeader
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/**
* Creates an artificial sam header, matching the parameters, chromosomes which will be labeled chr1, chr2, etc
*
* @param numberOfChromosomes the number of chromosomes to create
* @param startingChromosome the starting number for the chromosome (most likely set to 1)
* @param chromosomeSize the length of each chromosome
* @return
*/
public static SAMFileHeader createArtificialSamHeader(int numberOfChromosomes, int startingChromosome, int chromosomeSize) {
SAMFileHeader header = new SAMFileHeader();
header.setSortOrder(htsjdk.samtools.SAMFileHeader.SortOrder.coordinate);
SAMSequenceDictionary dict = new SAMSequenceDictionary();
// make up some sequence records
for (int x = startingChromosome; x < startingChromosome + numberOfChromosomes; x++) {
SAMSequenceRecord rec = new SAMSequenceRecord("chr" + (x), chromosomeSize /* size */);
rec.setSequenceLength(chromosomeSize);
dict.addSequence(rec);
}
header.setSequenceDictionary(dict);
return header;
}
示例9: createDictionary
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
private SAMSequenceDictionary createDictionary(List<Chromosome> chromosomes) {
SAMSequenceDictionary newDictionary = new SAMSequenceDictionary();
for (Chromosome chromosome : chromosomes) {
newDictionary.addSequence(new SAMSequenceRecord(chromosome.getName(), chromosome.getSize()));
}
return newDictionary;
}
示例10: ReadDict
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
static SAMSequenceDictionary ReadDict(File fastafile) {
SAMSequenceDictionary dict = new SAMSequenceDictionary();
try {
BufferedReader reader = null;
if(fastafile.getName().endsWith(".gz")) {
reader = new BufferedReader(new FileReader(fastafile.getCanonicalPath().substring(0,fastafile.getCanonicalPath().lastIndexOf(".gz") ) +".fai"));
}
else {
reader = new BufferedReader(new FileReader(fastafile.getCanonicalPath() +".fai"));
}
String line;
String[] split;
while((line = reader.readLine())!=null) {
split = line.split("\t");
SAMSequenceRecord record = new SAMSequenceRecord(split[0], Integer.parseInt(split[1]));
dict.addSequence(record);
}
reader.close();
}
catch(Exception e){
e.printStackTrace();
}
return dict;
}
示例11: setSamSeqDictFromGenomeFile
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
/** Get SamSequenceDictionary either from local file or from built-in resources.
* If reading from resources, "genome" is the tag before '.genome'. E.g.
* 'hg19' will read file hg19.genome
* */
private boolean setSamSeqDictFromGenomeFile(String genome) throws IOException {
SAMSequenceDictionary samSeqDict= new SAMSequenceDictionary();
BufferedReader reader=null;
try{
// Attempt to read from resource
InputStream res= Main.class.getResourceAsStream("/genomes/" + genome + ".genome");
reader= new BufferedReader(new InputStreamReader(res));
} catch (NullPointerException e){
try{
// Read from local file
reader= new BufferedReader(new FileReader(new File(genome)));
} catch (FileNotFoundException ex){
return false;
}
}
String line = null;
while ((line = reader.readLine()) != null) {
if(line.trim().isEmpty() || line.trim().startsWith("#")){
continue;
}
String[] chromLine= line.split("\t");
SAMSequenceRecord sequenceRecord = new SAMSequenceRecord(chromLine[0], Integer.parseInt(chromLine[1]));
samSeqDict.addSequence(sequenceRecord);
}
reader.close();
this.setSamSeqDictSource(genome);
this.setSamSeqDict(samSeqDict);
return true;
}
示例12: createGenomeLocParser
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
private GenomeLocParser createGenomeLocParser() {
SAMSequenceDictionary dict = new SAMSequenceDictionary();
for (Chromosome chr : GenomeManager.getInstance().getCurrentGenome().getChromosomes()) {
dict.addSequence(new SAMSequenceRecord(chromoNameToStandard(chr.getName()), chr.getLength()));
}
return new GenomeLocParser(dict);
}
示例13: getSequenceDictionary
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
public static SAMSequenceDictionary getSequenceDictionary(Configuration conf) throws IOException {
int counter = conf.getInt(dictionaryCount, 0);
SAMSequenceDictionary dict = new SAMSequenceDictionary();
for(int i = 0; i < counter; i++) {
String seqName = conf.get(dictionarySequenceName + i);
int seqLength = conf.getInt(dictionarySequenceLength + i, 0);
SAMSequenceRecord seq = new SAMSequenceRecord(seqName, seqLength);
dict.addSequence(seq);
}
return dict;
}
示例14: testIsSequenceDictionaryFromIndexNegative
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test
public void testIsSequenceDictionaryFromIndexNegative() throws Exception {
SAMSequenceDictionary dict = new SAMSequenceDictionary();
dict.addSequence(new SAMSequenceRecord("1", 99));
dict.addSequence(new SAMSequenceRecord("2", 99));
Assert.assertFalse(IndexUtils.isSequenceDictionaryFromIndex(dict));
}
示例15: testMalformedQueryFail
import htsjdk.samtools.SAMSequenceDictionary; //导入方法依赖的package包/类
@Test(expectedExceptions = NumberFormatException.class)
public void testMalformedQueryFail() {
final SAMSequenceDictionary sd = getAmbiguousSequenceDictionary();
sd.addSequence(new SAMSequenceRecord("contig:1-10", 99));
sd.addSequence(new SAMSequenceRecord("contig", 99));
IntervalUtils.getResolvedIntervals("contig:abc-dce", sd);
}