Exemplo n.º 1
0
    def availability_range(self):
        """Assemble the date/time range of the articles availability."""
        start = self.available_from
        end = self.available_until

        if start:
            if end:
                return Range.closedOpen(start, end)
            else:
                return Range.atLeast(start)
        else:
            if end:
                return Range.lessThan(end)
            else:
                return range_all(datetime)
Exemplo n.º 2
0
    def availability_range(self) -> Range:
        """Assemble the date/time range of the articles availability."""
        start = self.available_from
        end = self.available_until

        if start:
            if end:
                return Range.closedOpen(start, end)
            else:
                return Range.atLeast(start)
        else:
            if end:
                return Range.lessThan(end)
            else:
                return range_all(datetime)
Exemplo n.º 3
0
def merge_segments_for_chr(s):
    merged = RangeSet([Range.closed(*t) for t in zip(s.SegStart, s.SegEnd)])
    seg_start = np.array([x.lowerEndpoint() for x in merged.ranges])
    seg_end = np.array([x.upperEndpoint() for x in merged.ranges])
    seg_no = len(seg_start)
    return pd.DataFrame.from_dict(
        OrderedDict([
            ('SegStart', seg_start),
            ('SegEnd', seg_end),
            ('SnpStart', seg_start),
            ('SnpEnd', seg_end),
            ('NoSnp', np.zeros(seg_no, dtype=int)),
            ('Length', (seg_end - seg_start)),
            ('NoSnp', np.zeros(seg_no, dtype=int)),
            ('Unit', np.repeat('bp', seg_no)),
            ('NoMismatch', np.zeros(seg_no, dtype=int)),
            ('Res1', np.zeros(seg_no, dtype=int)),
            ('Res2', np.zeros(seg_no, dtype=int)),
            ('Fam1', np.repeat('-', seg_no)),
            ('Fam2', np.repeat('-', seg_no)),
        ]))
Exemplo n.º 4
0
def range_all(theType: Any) -> Range:
    """Create a range than contains every value of the given type."""
    return Range(Cut.belowAll(theType=theType), Cut.aboveAll(theType=theType))
Exemplo n.º 5
0
 def to_range(self):
     return Range.closedOpen(self.start, self.end)