code: def sam_pair_to_insert(s1, s2):
      '''Returns insert size from pair of sam records, as long as their orientation is "innies".
         Otherwise returns None.'''
      if s1.is_unmapped or s2.is_unmapped or (s1.tid != s2.tid) or (s1.is_reverse == s2.is_reverse):
          return None
  
      # If here, reads are both mapped to the same ref, and in opposite orientations
      if s1.is_reverse:
          end = s1.reference_end - 1
          start = s2.reference_start
      else:
          end = s2.reference_end - 1
          start = s1.reference_start
  
      if start < end:
          return end - start + 1
      else:
          return Nonf sam_pair_to_insert(s1, s2):
      '''Returns insert size from pair of sam records, as long as their orientation is "innies".
         Otherwise returns None.'''
      if s1.is_unmapped or s2.is_unmapped or (s1.tid != s2.tid) or (s1.is_reverse == s2.is_reverse):
          return None
  
      # If here, reads are both mapped to the same ref, and in opposite orientations
      if s1.is_reverse:
          end = s1.reference_end - 1
          start = s2.reference_start
      else:
          end = s2.reference_end - 1
          start = s1.reference_start
  
      if start < end:
          return end - start + 1
      else:
          return None
docs: Returns insert size from pair of sam records, as long as their orientation is "innies".
         Otherwise returns None.