def parse_gff_attributes(attr_str):
 attributes_list = attr_str.split(';')
 attributes = {}
 for name_value_pair in attributes_list:
  pair = name_value_pair.strip().split('=')
  if (len(pair) == 1):
   pair = name_value_pair.strip().split('"')
  if (len(pair) == 1):
   continue
  if (pair == ''):
   continue
  name = pair[0].strip()
  if (name == ''):
   continue
  value = pair[1].strip(' "')
  attributes[name] = value
 if (len(attributes) == 0):
  attributes['group'] = attr_str
 return attributes

def parse_gff_attributes ( attr_str ) : attributes_list = attr_str . split ( ';' ) attributes = { } for name_value_pair in attributes_list : pair = name_value_pair . strip ( ) . split ( '=' ) if ( len ( pair ) == 1 ) : pair = name_value_pair . strip ( ) . split ( '"' ) if ( len ( pair ) == 1 ) : continue if ( pair == '' ) : continue name = pair [ 0 ] . strip ( ) if ( name == '' ) : continue value = pair [ 1 ] . strip ( ' "' ) attributes [ name ] = value if ( len ( attributes ) == 0 ) : attributes [ 'group' ] = attr_str return attributes
parses a gff/gtf attribute string and returns a dictionary of name-value pairs .