parameters: (self, filename)
docstring: Loads a Graph from a GFA file. It does not load any GFA file, but makes some restrictions:
          1) The segment names must be integers.
          2) The depths should be stored in a dp tag.
          3) All link overlaps are the same (equal to the graph overlap value).
docstring_summary: Loads a Graph from a GFA file. It does not load any GFA file, but makes some restrictions:
          1) The segment names must be integers.
          2) The depths should be stored in a dp tag.
          3) All link overlaps are the same (equal to the graph overlap value).
docstring_tokens: Loads a Graph from a GFA file . It does not load any GFA file but makes some restrictions : 1 ) The segment names must be integers . 2 ) The depths should be stored in a dp tag . 3 ) All link overlaps are the same ( equal to the graph overlap value ) .
function: def load_from_gfa(self, filename):
          """
          Loads a Graph from a GFA file. It does not load any GFA file, but makes some restrictions:
          1) The segment names must be integers.
          2) The depths should be stored in a dp tag.
          3) All link overlaps are the same (equal to the graph overlap value).
          """
          # Load in the segments.
          with open(filename, 'rt') as gfa_file:
              for line in gfa_file:
                  if line.startswith('S'):
                      line_parts = line.strip().split('\t')
                      num = int(line_parts[1])
                      depth = 1.0
                      for part in line_parts:
                          if part.lower().startswith('dp:'):
                              depth = float(part[5:])
                          if part.lower().startswith('ml:'):
                              self.manual_multiplicity[num] = int(part[5:])
                      sequence = line_parts[2]
                      self.segments[num] = Segment(num, depth, sequence, True)
                      self.segments[num].build_other_sequence_if_necessary()
                  if line.startswith('i'):
                      line_parts = line.strip().split('\t')
                      try:
                          self.insert_size_mean = float(line_parts[1])
                          self.insert_size_deviation = float(line_parts[2])
                      except ValueError:
                          pass
  
          # Load in the links.
          with open(filename, 'rt') as gfa_file:
              for line in gfa_file:
                  if line.startswith('L'):
                      line_parts = line.strip().split('\t')
                      start = signed_string_to_int(line_parts[1] + line_parts[2])
                      end = signed_string_to_int(line_parts[3] + line_parts[4])
                      if start not in self.forward_links:
                          self.forward_links[start] = [end]
                      else:
                          self.forward_links[start].append(end)
              self.forward_links = build_rc_links_if_necessary(self.forward_links)
              self.reverse_links = build_reverse_links(self.forward_links)
          self.sort_link_order()
  
          # Load in the paths.
          with open(filename, 'rt') as gfa_file:
              for line in gfa_file:
                  if line.startswith('P'):
                      line_parts = line.strip().split('\t')
                      path_name = line_parts[1]
                      segments = [signed_string_to_int(x) for x in line_parts[2].split(',')]
                      if len(segments) > 1:
                          self.paths[path_name] = segments
function_tokens: def load_from_gfa ( self , filename ) : # Load in the segments. with open ( filename , 'rt' ) as gfa_file : for line in gfa_file : if line . startswith ( 'S' ) : line_parts = line . strip ( ) . split ( '\t' ) num = int ( line_parts [ 1 ] ) depth = 1.0 for part in line_parts : if part . lower ( ) . startswith ( 'dp:' ) : depth = float ( part [ 5 : ] ) if part . lower ( ) . startswith ( 'ml:' ) : self . manual_multiplicity [ num ] = int ( part [ 5 : ] ) sequence = line_parts [ 2 ] self . segments [ num ] = Segment ( num , depth , sequence , True ) self . segments [ num ] . build_other_sequence_if_necessary ( ) if line . startswith ( 'i' ) : line_parts = line . strip ( ) . split ( '\t' ) try : self . insert_size_mean = float ( line_parts [ 1 ] ) self . insert_size_deviation = float ( line_parts [ 2 ] ) except ValueError : pass # Load in the links. with open ( filename , 'rt' ) as gfa_file : for line in gfa_file : if line . startswith ( 'L' ) : line_parts = line . strip ( ) . split ( '\t' ) start = signed_string_to_int ( line_parts [ 1 ] + line_parts [ 2 ] ) end = signed_string_to_int ( line_parts [ 3 ] + line_parts [ 4 ] ) if start not in self . forward_links : self . forward_links [ start ] = [ end ] else : self . forward_links [ start ] . append ( end ) self . forward_links = build_rc_links_if_necessary ( self . forward_links ) self . reverse_links = build_reverse_links ( self . forward_links ) self . sort_link_order ( ) # Load in the paths. with open ( filename , 'rt' ) as gfa_file : for line in gfa_file : if line . startswith ( 'P' ) : line_parts = line . strip ( ) . split ( '\t' ) path_name = line_parts [ 1 ] segments = [ signed_string_to_int ( x ) for x in line_parts [ 2 ] . split ( ',' ) ] if len ( segments ) > 1 : self . paths [ path_name ] = segments