code: def update_from_sam(self, sam, sam_reader):
          '''Updates graph info from a pysam.AlignedSegment object'''
          if sam.is_unmapped \
            or sam.mate_is_unmapped \
            or (sam.reference_id == sam.next_reference_id):
              return
  
          new_link = link.Link(sam, sam_reader, self.ref_lengths)
          read_name = sam.query_name
  
          if read_name in self.partial_links:
              new_link.merge(self.partial_links[read_name])
              del self.partial_links[read_name]
              key = tuple(sorted((new_link.refnames[0], new_link.refnames[1])))
              if key not in self.links:
                  self.links[key] = []
              new_link.sort()
              self.links[key].append(new_link)
          else:
              self.partial_links[read_name] = new_linf update_from_sam(self, sam, sam_reader):
          '''Updates graph info from a pysam.AlignedSegment object'''
          if sam.is_unmapped \
            or sam.mate_is_unmapped \
            or (sam.reference_id == sam.next_reference_id):
              return
  
          new_link = link.Link(sam, sam_reader, self.ref_lengths)
          read_name = sam.query_name
  
          if read_name in self.partial_links:
              new_link.merge(self.partial_links[read_name])
              del self.partial_links[read_name]
              key = tuple(sorted((new_link.refnames[0], new_link.refnames[1])))
              if key not in self.links:
                  self.links[key] = []
              new_link.sort()
              self.links[key].append(new_link)
          else:
              self.partial_links[read_name] = new_link
docs: Updates graph info from a pysam.AlignedSegment object