Exemplo n.º 1
0
 def test_make_position(self):
   self.assertEqual(
       ranges.make_position('chr1', 10),
       position_pb2.Position(
           reference_name='chr1', position=10, reverse_strand=False))
   self.assertEqual(
       ranges.make_position('chr2', 100, reverse_strand=True),
       position_pb2.Position(
           reference_name='chr2', position=100, reverse_strand=True))
Exemplo n.º 2
0
def make_position(chrom, position, reverse_strand=False):
    """Returns a nucleus.genomics.v1.Position.

  Args:
    chrom: str. The chromosome name.
    position: int. The start position (0-based, inclusive).
    reverse_strand: bool. If True, indicates the position is on the negative
      strand.
  """
    return position_pb2.Position(reference_name=chrom,
                                 position=position,
                                 reverse_strand=reverse_strand)
Exemplo n.º 3
0
def make_read(bases,
              start,
              quals=None,
              cigar=None,
              mapq=50,
              chrom='chr1',
              name=None):
  """Makes a nucleus.genomics.v1.Read for testing."""
  if quals and len(bases) != len(quals):
    raise ValueError('Incompatable bases and quals', bases, quals)
  read = reads_pb2.Read(
      fragment_name=name if name else 'read_' + str(make_read.counter),
      proper_placement=True,
      read_number=1,
      number_reads=2,
      aligned_sequence=bases,
      aligned_quality=quals,
      alignment=reads_pb2.LinearAlignment(
          position=position_pb2.Position(reference_name=chrom, position=start),
          mapping_quality=mapq,
          cigar=_cigar.to_cigar_units(cigar) if cigar else []))
  make_read.counter += 1
  return read
Exemplo n.º 4
0
def make_read(bases,
              quals=None,
              cigar=None,
              mapq=50,
              chrom='chr1',
              start=1,
              name='read'):
    """Makes a third_party.nucleus.protos.Read for testing."""
    if quals and len(bases) != len(quals):
        raise ValueError('Incompatable bases and quals', bases, quals)
    read = reads_pb2.Read(
        fragment_name=name,
        proper_placement=True,
        read_number=1,
        number_reads=2,
        aligned_sequence=bases,
        aligned_quality=quals,
        alignment=reads_pb2.LinearAlignment(
            position=position_pb2.Position(reference_name=chrom,
                                           position=start),
            mapping_quality=mapq,
            cigar=_cigar.to_cigar_units(cigar) if cigar else []))
    return read
Exemplo n.º 5
0
def make_position(chrom, position, reverse_strand=False):
    """Makes a third_party.nucleus.protos.Position."""
    return position_pb2.Position(reference_name=chrom,
                                 position=position,
                                 reverse_strand=reverse_strand)