def _new_rec(self, name: str, chrom: str, start: int, attrs: Optional[Dict[str, Any]]) -> AlignedSegment: """Generates a new AlignedSegment. Sets the segment up with the correct header and adds the RG attribute if not contained in attrs. Args: name: the name of the read/template chrom: the chromosome to which the read is mapped start: the start position of the read on the chromosome attrs: an optional dictionary of SAM attributes with two-char keys Returns: AlignedSegment: an aligned segment with name, chrom, pos, attributes the read group, and the unmapped flag all set appropriately. """ if chrom is not sam.NO_REF_NAME and chrom not in self._seq_lookup: raise ValueError( f"{chrom} is not a valid chromosome name in this builder.") rec = AlignedSegment(header=self._samheader) rec.query_name = name rec.reference_name = chrom rec.reference_start = start rec.mapping_quality = self.mapping_quality if chrom == sam.NO_REF_NAME or start == sam.NO_REF_POS: rec.is_unmapped = True attrs = attrs if attrs else dict() if "RG" not in attrs: attrs["RG"] = self.rg_id() rec.set_tags(list(attrs.items())) return rec
qe=14, rq=0.80, sn=[2.0, 3.0, 5.0, 6.0], ip=[15]*14, pw=[16]*14, zm=42, cx=2, # Now, the pulse stuff pc = " GAgggTTACAcccGATaaaTACA", pa = [5]*23, #pkmean pm = [4]*23, #pkmid pd = [3]*23, #prePulseFrames px = [2]*23, #pulseWidthInFrames sf = range(3, 1000, 5)[:23] # startFrame ) pulsePeer.set_tags(tags.items()) mockBamReader = Mock( readGroupInfo=lambda x: Mock(ID=0, MovieName="FakeMovie", ReadType="SUBREAD", SequencingChemistry="FakeChemistry", FrameRate=100.0)) bamRecord = BamAlignment(mockBamReader, pulsePeer) mockVpReader = Mock(movieName="FakeMovie", pulseFeatureDescs= { "preBaseFrames" : FeatureDesc("preBaseFrames" , "Ipd:Frames" , "ip", "identity", np.uint16, np.uint16), "baseWidthInFrames" : FeatureDesc("baseWidthInFrames" , "PulseWidth:Frames" , "pw", "identity", np.uint16, np.uint16) })
qe=14, rq=0.80, sn=[2.0, 3.0, 5.0, 6.0], ip=[15] * 14, pw=[16] * 14, zm=42, cx=2, # Now, the pulse stuff pc=" GAgggTTACAcccGATaaaTACA", pa=[5] * 23, #pkmean pm=[4] * 23, #pkmid pd=[3] * 23, #prePulseFrames px=[2] * 23, #pulseWidthInFrames sf=range(3, 1000, 5)[:23] # startFrame ) pulsePeer.set_tags(tags.items()) mockBamReader = Mock( readGroupInfo=lambda x: Mock(ID=0, MovieName="FakeMovie", ReadType="SUBREAD", SequencingChemistry="FakeChemistry", FrameRate=100.0)) bamRecord = BamAlignment(mockBamReader, pulsePeer) mockVpReader = Mock(movieName="FakeMovie", pulseFeatureDescs={ "preBaseFrames": FeatureDesc("preBaseFrames", "Ipd:Frames", "ip", "identity", np.uint16, np.uint16), "baseWidthInFrames":