本文整理汇总了Java中htsjdk.samtools.util.SequenceUtil.reverseComplement方法的典型用法代码示例。如果您正苦于以下问题:Java SequenceUtil.reverseComplement方法的具体用法?Java SequenceUtil.reverseComplement怎么用?Java SequenceUtil.reverseComplement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htsjdk.samtools.util.SequenceUtil
的用法示例。
在下文中一共展示了SequenceUtil.reverseComplement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearReadAlignment
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* Returns input read with alignment-related info cleared
*/
private static GATKRead clearReadAlignment(final GATKRead read, final SAMFileHeader header) {
final GATKRead newRead = new SAMRecordToGATKReadAdapter(new SAMRecord(header));
newRead.setName(read.getName());
newRead.setBases(read.getBases());
newRead.setBaseQualities(read.getBaseQualities());
if (read.isReverseStrand()) {
SequenceUtil.reverseComplement(newRead.getBases());
SequenceUtil.reverseQualities(newRead.getBaseQualities());
}
newRead.setIsUnmapped();
newRead.setIsPaired(read.isPaired());
if (read.isPaired()) {
newRead.setMateIsUnmapped();
if (read.isFirstOfPair()) {
newRead.setIsFirstOfPair();
} else if (read.isSecondOfPair()) {
newRead.setIsSecondOfPair();
}
}
final String readGroup = read.getReadGroup();
if (readGroup != null) {
newRead.setAttribute(SAMTag.RG.name(), readGroup);
}
return newRead;
}
示例2: reset
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
void reset(EvidenceRecord evidenceRecord) {
this.evidenceRecord = evidenceRecord;
negative = "-".equals(evidenceRecord.Strand);
baseBuf.clear();
scoreBuf.clear();
if (evidenceRecord.Strand.equals("+")) {
baseBuf.put(evidenceRecord.Sequence.getBytes());
scoreBuf.put(SAMUtils.fastqToPhred(evidenceRecord.Scores));
} else {
byte[] bytes = evidenceRecord.Sequence.getBytes();
SequenceUtil.reverseComplement(bytes);
baseBuf.put(bytes);
bytes = SAMUtils.fastqToPhred(evidenceRecord.Scores);
SequenceUtil.reverseQualities(bytes);
scoreBuf.put(bytes);
}
baseBuf.flip();
scoreBuf.flip();
firstHalf.clear();
secondHalf.clear();
}
示例3: getMatcher
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* See {@link #search(String, Strand, String, int, byte[])} for explanation of parameters
* @param pattern
* @param strand
* @param sequence
* @return
*/
static Matcher getMatcher(String pattern, Strand strand, byte[] sequence){
byte[] seq = sequence;
if(strand == Strand.NEGATIVE){
//sequence could be quite long, cloning it might take up a lot of memory
//and is un-necessary if we are careful.
//seq = seq.clone();
SequenceUtil.reverseComplement(seq);
}
Pattern regex = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
String stringSeq = new String(seq);
return regex.matcher(stringSeq);
}
示例4: CustomAdapterPair
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
CustomAdapterPair(final String fivePrime, final String threePrime) {
this.threePrime = threePrime;
this.threePrimeBytes = StringUtil.stringToBytes(threePrime);
this.fivePrime = fivePrime;
this.fivePrimeReadOrder = SequenceUtil.reverseComplement(fivePrime);
this.fivePrimeBytes = StringUtil.stringToBytes(fivePrime);
this.fivePrimeReadOrderBytes = StringUtil.stringToBytes(fivePrimeReadOrder);
}
示例5: forSimpleTandemDuplicationExpansion
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* 40-'A' + 10-'C' + 40-'G' is expanded to 40-'A' + 20-'C' + 40-'G' (forward strand representation)
* Return a list of two entries for positive and reverse strand representations.
*/
private static List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>>
forSimpleTandemDuplicationExpansion(final ByteArrayOutputStream outputStream) throws IOException {
final List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>> result = new ArrayList<>();
// simple tandem duplication expansion '+' strand representation
final byte[] leftRefFlank = makeDummySequence(40, (byte)'A');
final byte[] rightRefFlank = makeDummySequence(40, (byte)'G');
final byte[] doubleDup = makeDummySequence(20, (byte)'C');
outputStream.reset();
outputStream.write(leftRefFlank);outputStream.write(doubleDup);outputStream.write(rightRefFlank);
byte[] contigSeq = outputStream.toByteArray();
AlignmentInterval region1 = new AlignmentInterval(new SimpleInterval("21", 100001, 100050), 1 ,50, TextCigarCodec.decode("50M50S"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
AlignmentInterval region2 = new AlignmentInterval(new SimpleInterval("21", 100041, 100090), 51 ,100, TextCigarCodec.decode("50S50M"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpoints = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpoints, "asm000001:tig00001"));
// simple tandem duplication expansion '-' strand representation
SequenceUtil.reverseComplement(leftRefFlank);
SequenceUtil.reverseComplement(rightRefFlank);
SequenceUtil.reverseComplement(doubleDup);
outputStream.reset();
outputStream.write(rightRefFlank);outputStream.write(doubleDup);outputStream.write(leftRefFlank);
contigSeq = outputStream.toByteArray();
region1 = new AlignmentInterval(new SimpleInterval("21", 100041, 100090), 1 ,50, TextCigarCodec.decode("50M50S"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
region2 = new AlignmentInterval(new SimpleInterval("21", 100001, 100050), 51 ,100, TextCigarCodec.decode("50S50M"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpointsDetectedFromReverseStrand = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpointsDetectedFromReverseStrand, "asm000001:tig00001"));
return result;
}
示例6: forSimpleDeletion
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* 40-'A' + 10-'C'+10-'T' + 40-'G' where the segment 10-'C'+10-'T' is deleted (forward strand representation description).
*
* Return a list of two entries for positive and reverse strand representations.
*/
private static List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>>
forSimpleDeletion(final ByteArrayOutputStream outputStream) throws IOException {
final List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>> result = new ArrayList<>();
// simple deletion '+' strand representation
final byte[] leftRefFlank = makeDummySequence(40, (byte)'A');
final byte[] rightRefFlank = makeDummySequence(40, (byte)'G');
outputStream.reset();
outputStream.write(leftRefFlank);outputStream.write(rightRefFlank);
byte[] contigSeq = outputStream.toByteArray();
AlignmentInterval region1 = new AlignmentInterval(new SimpleInterval("21", 100001, 100040), 1 ,40, TextCigarCodec.decode("40M40S"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
AlignmentInterval region2 = new AlignmentInterval(new SimpleInterval("21", 100061, 100100), 41 ,80, TextCigarCodec.decode("40S40M"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpoints = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpoints, "asm000001:tig00001"));
// simple deletion '-' strand representation
SequenceUtil.reverseComplement(leftRefFlank);
SequenceUtil.reverseComplement(rightRefFlank);
outputStream.reset();
outputStream.write(rightRefFlank);outputStream.write(leftRefFlank);
contigSeq = outputStream.toByteArray();
region1 = new AlignmentInterval(new SimpleInterval("21", 100061, 100100), 1 ,40, TextCigarCodec.decode("40M40S"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
region2 = new AlignmentInterval(new SimpleInterval("21", 100001, 100040), 41 ,80, TextCigarCodec.decode("40S40M"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpointsDetectedFromReverseStrand = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpointsDetectedFromReverseStrand, "asm000001:tig00001"));
return result;
}
示例7: addBases
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/** Method that takes in the reference sequence this bait is on and caches the bait's bases. */
public void addBases(final ReferenceSequence reference, final boolean useStrandInfo) {
final byte[] tmp = new byte[length()];
System.arraycopy(reference.getBases(), getStart() - 1, tmp, 0, length());
if (useStrandInfo && isNegativeStrand()) {
SequenceUtil.reverseComplement(tmp);
}
setBases(tmp);
}
示例8: forDeletionWithHomology
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* 40-'C' + 'ATCG' + 34 bases of unique sequence + 'ATCG' + 40-'T' is shrunk to 40-'C' + 'ATCG' + 40-'T' (forward strand representation)
* Return a list of two entries for positive and reverse strand representations.
*/
private static List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>>
forDeletionWithHomology(final ByteArrayOutputStream outputStream) throws IOException {
final List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>> result = new ArrayList<>();
// simple deletion with homology '+' strand representation
final byte[] leftRefFlank = makeDummySequence(40, (byte)'C');
final byte[] rightRefFlank = makeDummySequence(40, (byte)'T');
final byte[] homology = new byte[]{'A', 'T', 'C', 'G'};
outputStream.reset();
outputStream.write(leftRefFlank);outputStream.write(homology);outputStream.write(rightRefFlank);
byte[] contigSeq = outputStream.toByteArray();
AlignmentInterval region1 = new AlignmentInterval(new SimpleInterval("21", 100001, 100044), 1 ,44, TextCigarCodec.decode("44M40S"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
AlignmentInterval region2 = new AlignmentInterval(new SimpleInterval("21", 100079, 100122), 41 ,84, TextCigarCodec.decode("40S44M"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpoints = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpoints, "asm000001:tig00001"));
// simple deletion with homology '-' strand representation
SequenceUtil.reverseComplement(leftRefFlank);
SequenceUtil.reverseComplement(rightRefFlank);
SequenceUtil.reverseComplement(homology);
outputStream.reset();
outputStream.write(rightRefFlank);outputStream.write(homology);outputStream.write(leftRefFlank);
contigSeq = outputStream.toByteArray();
region1 = new AlignmentInterval(new SimpleInterval("21", 100079, 100122), 1 ,44, TextCigarCodec.decode("44M40S"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
region2 = new AlignmentInterval(new SimpleInterval("21", 100001, 100044), 41 ,84, TextCigarCodec.decode("40S44M"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpointsDetectedFromReverseStrand = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpointsDetectedFromReverseStrand, "asm000001:tig00001"));
return result;
}
示例9: getReadBases
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* Returns an array of bytes representing the bases in the read,
* reverse complementing them if the read is on the negative strand
*/
private static byte[] getReadBases(final SAMRecord read) {
if (!read.getReadNegativeStrandFlag()) {
return read.getReadBases();
}
else {
final byte[] reverseComplementedBases = new byte[read.getReadBases().length];
System.arraycopy(read.getReadBases(), 0, reverseComplementedBases, 0, reverseComplementedBases.length);
SequenceUtil.reverseComplement(reverseComplementedBases);
return reverseComplementedBases;
}
}
示例10: IlluminaAdapterPair
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
private IlluminaAdapterPair(final String fivePrime, final String threePrime) {
this.threePrime = threePrime;
this.threePrimeBytes = StringUtil.stringToBytes(threePrime);
this.fivePrime = fivePrime;
this.fivePrimeReadOrder = SequenceUtil.reverseComplement(fivePrime);
this.fivePrimeBytes = StringUtil.stringToBytes(fivePrime);
this.fivePrimeReadOrderBytes = StringUtil.stringToBytes(fivePrimeReadOrder);
}
示例11: doWork
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
@Override
protected int doWork() {
IOUtil.assertFileIsReadable(INTERVAL_LIST);
IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE);
IOUtil.assertFileIsWritable(OUTPUT);
final IntervalList intervals = IntervalList.fromFile(INTERVAL_LIST);
final ReferenceSequenceFile ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(REFERENCE_SEQUENCE);
SequenceUtil.assertSequenceDictionariesEqual(intervals.getHeader().getSequenceDictionary(), ref.getSequenceDictionary());
final BufferedWriter out = IOUtil.openFileForBufferedWriting(OUTPUT);
for (final Interval interval : intervals) {
final ReferenceSequence seq = ref.getSubsequenceAt(interval.getContig(), interval.getStart(), interval.getEnd());
final byte[] bases = seq.getBases();
if (interval.isNegativeStrand()) SequenceUtil.reverseComplement(bases);
try {
out.write(">");
out.write(interval.getName());
out.write("\n");
for (int i=0; i<bases.length; ++i) {
if (i > 0 && i % LINE_LENGTH == 0) out.write("\n");
out.write(bases[i]);
}
out.write("\n");
}
catch (IOException ioe) {
throw new PicardException("Error writing to file " + OUTPUT.getAbsolutePath(), ioe);
}
}
CloserUtil.close(out);
return 0;
}
示例12: testDetermineVariantTranscriptEffect_reverseStrand
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
@Test
public void testDetermineVariantTranscriptEffect_reverseStrand() {
Annotation transcript = new Annotation()
.setReferenceName("1")
.setStart(2L)
.setEnd(20L)
.setReverseStrand(true)
.setTranscript(new Transcript()
.setCodingSequence(new CodingSequence().setStart(3L).setEnd(18L))
.setExons(ImmutableList.of(
new Exon().setStart(2L).setEnd(7L).setFrame(2),
new Exon().setStart(10L).setEnd(20L).setFrame(1))
));
String bases = SequenceUtil.reverseComplement(
// First exon [10, 20)
"AC" + // 5' UTR
"ATG" + "ACG" + "GT" +
// intron
"CCC" +
// Second exon [2, 7)
"G" + "TAG" +
"G"); // 3' UTR
assertEquals("ATG -> ACG (reverse complement), AA is M -> T",
VariantEffect.NONSYNONYMOUS_SNP,
AnnotationUtils.determineVariantTranscriptEffect(16L, "G", transcript, bases));
assertEquals("TAG -> CAG (reverse complement), AA is STOP -> Q",
VariantEffect.STOP_LOSS,
AnnotationUtils.determineVariantTranscriptEffect(5L, "G", transcript, bases));
assertNull("mutates intron",
AnnotationUtils.determineVariantTranscriptEffect(9L, "C", transcript, bases));
assertNull("mutates 5' UTR",
AnnotationUtils.determineVariantTranscriptEffect(19L, "C", transcript, bases));
}
示例13: forSimpleTandemDuplicationExpansionWithNovelInsertion
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* System.out.println(new String(reference.getReferenceBases(dummyOptions, new SimpleInterval("21", 25297100, 25297300)).getBases()));
* leftFlank: chr21:25297101-25297163
* repeat: chr21:25297164-25297252
* rightFlank: chr21:25297253-25297300
* GTTAGTAGATATTCTAGCTGACTCAGTTCAGTGTTGCTATGATTAAACAAGAGTGAGTTCCCT
* AAAAGTAAATGTTATAAGAAATCTTAAGTATTATTTTCTTATGTTTCTAGCCTAATAAAGTGCTTTTATTAAAGCACTTTATTTAAAGG
* CATTATTGATATTTCATTATGTTCAACAGATGGAGTTAATGTGAATGT
*
* insertedSequenceForwardStrandRep: CTCTCTCTCT
*
* Return a list of two entries for positive and reverse strand representations.
*/
private static List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>>
forSimpleTandemDuplicationExpansionWithNovelInsertion(final ByteArrayOutputStream outputStream) throws IOException {
final List<Tuple4<AlignmentInterval, AlignmentInterval, NovelAdjacencyReferenceLocations, String>> result = new ArrayList<>();
// simple tandem duplication expansion with novel insertion '+' strand representation
final byte[] leftRefFlank = "GTTAGTAGATATTCTAGCTGACTCAGTTCAGTGTTGCTATGATTAAACAAGAGTGAGTTCCCT".getBytes(); //63
final byte[] rightRefFlank = "CATTATTGATATTTCATTATGTTCAACAGATGGAGTTAATGTGAATGT".getBytes(); //48
final byte[] insertedSeq = "CTCTCTCTCT".getBytes(); //10
final byte[] dup = "AAAAGTAAATGTTATAAGAAATCTTAAGTATTATTTTCTTATGTTTCTAGCCTAATAAAGTGCTTTTATTAAAGCACTTTATTTAAAGG".getBytes(); //89
outputStream.reset();
outputStream.write(leftRefFlank);outputStream.write(dup);outputStream.write(insertedSeq);outputStream.write(dup);outputStream.write(rightRefFlank);
byte[] contigSeq = outputStream.toByteArray();
AlignmentInterval region1 = new AlignmentInterval(new SimpleInterval("21", 25297101, 25297252), 1 ,152, TextCigarCodec.decode("152M147S"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
AlignmentInterval region2 = new AlignmentInterval(new SimpleInterval("21", 25297164, 25297300), 163 ,299, TextCigarCodec.decode("162S137M"), true, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpoints = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpoints, "asm000001:tig00001"));
// simple tandem duplication expansion with novel insertion '-' strand representation
SequenceUtil.reverseComplement(leftRefFlank);
SequenceUtil.reverseComplement(rightRefFlank);
SequenceUtil.reverseComplement(insertedSeq);
SequenceUtil.reverseComplement(dup);
outputStream.reset();
outputStream.write(rightRefFlank);outputStream.write(dup);outputStream.write(insertedSeq);outputStream.write(dup);outputStream.write(leftRefFlank);
contigSeq = outputStream.toByteArray();
region1 = new AlignmentInterval(new SimpleInterval("21", 25297164, 25297300), 1 ,137, TextCigarCodec.decode("137M162S"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
region2 = new AlignmentInterval(new SimpleInterval("21", 25297101, 25297252), 148 ,299, TextCigarCodec.decode("147S152M"), false, 60, 0, 100, ContigAlignmentsModifier.AlnModType.NONE);
final NovelAdjacencyReferenceLocations breakpointsDetectedFromReverseStrand = new NovelAdjacencyReferenceLocations(new ChimericAlignment(region1, region2, Collections.emptyList(), "asm000001:tig00001", seqDict), contigSeq, seqDict);
result.add(new Tuple4<>(region1, region2, breakpointsDetectedFromReverseStrand, "asm000001:tig00001"));
return result;
}
示例14: getHomology
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* @return Micro-homology sequence using two alignments of the same contig: as indicated by their overlap on the contig itself.
* Empty if they don't overlap on the contig.
*/
@VisibleForTesting
static String getHomology(final AlignmentInterval current, final AlignmentInterval next, final byte[] contigSequence) {
if (current.endInAssembledContig >= next.startInAssembledContig) {
final byte[] homologyBytes = Arrays.copyOfRange(contigSequence,
next.startInAssembledContig-1, current.endInAssembledContig);
if (current.referenceSpan.getStart() > next.referenceSpan.getStart()) {
SequenceUtil.reverseComplement(homologyBytes, 0, homologyBytes.length);
}
return new String(homologyBytes);
} else {
return "";
}
}
示例15: getInsertedSequence
import htsjdk.samtools.util.SequenceUtil; //导入方法依赖的package包/类
/**
* Note: not suitable for the most complicated case dealt with in {@link BreakpointComplications( ChimericAlignment )}
* @return Inserted sequence using two alignments of the same contig: as indicated by their separation on the the contig itself.
*/
@VisibleForTesting
static String getInsertedSequence(final AlignmentInterval current, final AlignmentInterval next, final byte[] contigSequence) {
if (current.endInAssembledContig < next.startInAssembledContig - 1) {
final byte[] insertedSequenceBytes = Arrays.copyOfRange(contigSequence,
current.endInAssembledContig, next.startInAssembledContig - 1);
if (current.referenceSpan.getStart() > next.referenceSpan.getStart()) {
SequenceUtil.reverseComplement(insertedSequenceBytes, 0, insertedSequenceBytes.length);
}
return new String(insertedSequenceBytes);
} else {
return "";
}
}