<s> """<STR_LIT>""" <EOL> import re <EOL> class Glam2Scan : <EOL> def __init__ ( self ) : <EOL> self . motifs = [ ] <EOL> self . matches = [ ] <EOL> class Motif : <EOL> pass <EOL> class Match : <EOL> """<STR_LIT>""" <EOL> header = "<STR_LIT:\t>" . join ( ( "<STR_LIT:id>" , "<STR_LIT:start>" , "<STR_LIT:end>" , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def __init__ ( self ) : <EOL> pass <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT:\t>" . join ( map ( str , <EOL> ( self . id , <EOL> self . start , <EOL> self . end , <EOL> self . strand , <EOL> self . sequence , <EOL> self . score ) ) ) <EOL> def parse ( infile ) : <EOL> '''<STR_LIT>''' <EOL> x = - <NUM_LIT:1> <EOL> for line in infile : <EOL> if line . startswith ( "<STR_LIT>" ) : <EOL> x = <NUM_LIT:4> <EOL> x -= <NUM_LIT:1> <EOL> if x == <NUM_LIT:0> : <EOL> break <EOL> if not line : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> gl = Glam2Scan ( ) <EOL> keep = False <EOL> for line in infile : <EOL> if line . strip ( ) == "<STR_LIT>" : <EOL> continue <EOL> if line . startswith ( "<STR_LIT:U+0020>" ) : <EOL> continue <EOL> m = Match ( ) <EOL> d = re . split ( "<STR_LIT>" , line [ : - <NUM_LIT:1> ] ) <EOL> if len ( d ) != <NUM_LIT:6> : <EOL> break <EOL> m . id , m . start , m . sequence , m . end , m . strand , m . score = d [ <NUM_LIT:0> ] , int ( d [ <NUM_LIT:1> ] ) - <NUM_LIT:1> , d [ <NUM_LIT:2> ] , int ( d [ <NUM_LIT:3> ] ) , d [ <NUM_LIT:4> ] , float ( d [ <NUM_LIT:5> ] ) <EOL> gl . matches . append ( m ) <EOL> return gl </s>
