public static BamAlignment CreateBamAlignment(string sequence, int position,
                                                      int matePosition, byte qualityForAll, bool isReverseMapped, uint mapQ = 30, byte[] qualities = null, CigarAlignment cigar = null, string name = null, bool isFirstMate = true)
        {
            var bamAlignment = new BamAlignment
            {
                Bases        = sequence,
                Position     = position - 1,
                CigarData    = cigar ?? new CigarAlignment(sequence.Length + "M"),
                Qualities    = qualities ?? Enumerable.Repeat(qualityForAll, sequence.Length).ToArray(),
                MatePosition = matePosition - 1,
                TagData      = new byte[0],
                RefID        = 1,
                MateRefID    = 1,
                Name         = name ?? "Alignment"
            };

            bamAlignment.SetIsFirstMate(isFirstMate);
            bamAlignment.MapQuality = mapQ;
            bamAlignment.SetIsReverseStrand(isReverseMapped);
            bamAlignment.SetIsMateReverseStrand(!isReverseMapped);
            return(bamAlignment);
        }
Beispiel #2
0
        public void BamAlignmentFlag_Setter_Tests()
        {
            var alignment = new BamAlignment();

            //Set Failed QC
            alignment.SetIsFailedQC(true);
            Assert.Equal((uint)512, alignment.AlignmentFlag);
            alignment.SetIsFailedQC(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Mate Unmapped
            alignment.SetIsMateUnmapped(true);
            Assert.Equal((uint)8, alignment.AlignmentFlag);
            alignment.SetIsMateUnmapped(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Mate Reverse Strand
            alignment.SetIsMateReverseStrand(true);
            Assert.Equal((uint)32, alignment.AlignmentFlag);
            alignment.SetIsMateReverseStrand(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Is Paired
            alignment.SetIsPaired(true);
            Assert.Equal((uint)1, alignment.AlignmentFlag);
            alignment.SetIsPaired(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Duplicate
            alignment.SetIsDuplicate(true);
            Assert.Equal((uint)1024, alignment.AlignmentFlag);
            alignment.SetIsDuplicate(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set First Mate
            alignment.SetIsFirstMate(true);
            Assert.Equal((uint)64, alignment.AlignmentFlag);
            alignment.SetIsFirstMate(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Proper Pair
            alignment.SetIsProperPair(true);
            Assert.Equal((uint)2, alignment.AlignmentFlag);
            alignment.SetIsProperPair(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Reverse Strand
            alignment.SetIsReverseStrand(true);
            Assert.Equal((uint)16, alignment.AlignmentFlag);
            alignment.SetIsReverseStrand(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Secondary Alignment
            alignment.SetIsSecondaryAlignment(true);
            Assert.Equal((uint)256, alignment.AlignmentFlag);
            alignment.SetIsSecondaryAlignment(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Second Mate
            alignment.SetIsSecondMate(true);
            Assert.Equal((uint)128, alignment.AlignmentFlag);
            alignment.SetIsSecondMate(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);

            //Set Unmapped
            alignment.SetIsUnmapped(true);
            Assert.Equal((uint)4, alignment.AlignmentFlag);
            alignment.SetIsUnmapped(false);
            Assert.Equal((uint)0, alignment.AlignmentFlag);
        }