pyvrs.slice module

class pyvrs.slice.AsyncVRSReaderSlice(path: str | Path, r, indices: List[int])[source]

Bases: Sequence

A slice into a VRS file, i.e. an arbitrary collection of records. Can be further sliced and indexed, but looses some of the smarts present in the full VRSReader (e.g. the ability to filter) and some richer properties like temporal information. This should be created only via AsyncVRSReader.async_read_record call.

class pyvrs.slice.VRSReaderSlice(path: str | Path, r, indices: List[int])[source]

Bases: Sequence

A slice into a VRS file, i.e. an arbitrary collection of records. Can be further sliced and indexed, but looses some of the smarts present in the full VRSReader (e.g. the ability to filter) and some richer properties like temporal information.

async pyvrs.slice.async_index_or_slice_records(path: Path, reader: AsyncVRSReader, vrs_indices: List[int], indices: int | slice) VRSRecord | AsyncVRSReaderSlice[source]

Shared logic to index or slice into a AsyncVRSReader or AsyncVRSReaderSlice. Returns either a AsyncVRSReaderSlice (if i is a slice or iterable) or a VRSRecord (if i is an integer).

Parameters:
  • path – a file path

  • reader – a reader instance which is based on the class extended from AsyncVRSReader

  • vrs_indices – a list of absolute indices for the VRS file that you are interested in. If you apply filter, this list should be the one after applying the filter.

  • indices – A set of indices or an index for vrs_indices that you want to read.

Returns:

AsyncVRSReaderSlice if the given indices is a slice, otherwise read a record and returns VRSRecord object.

pyvrs.slice.index_or_slice_records(path: Path, reader: VRSReader, vrs_indices: List[int], indices: int | slice) VRSRecord | VRSReaderSlice[source]

Shared logic to index or slice into a VRSReader or VRSReaderSlice. Returns either a VRSReaderSlice (if i is a slice or iterable) or a VRSRecord (if i is an integer).

Parameters:
  • path – a file path

  • reader – a reader instance which is based on the class extended from BaseVRSReader

  • vrs_indices – a list of absolute indices for the VRS file that you are interested in. If you apply filter, this list should be the one after applying the filter.

  • indices – A set of indices or an index for vrs_indices that you want to read.

Returns:

VRSReaderSlice if the given indices is a slice, otherwise read a record and returns VRSRecord object.