code: def liftover(args):
      
      p = OptionParser(liftover.__doc__)
      p.add_option("--checkvalid", default=False, action="store_true",
                  help="Check minscore, period and length")
      opts, args = p.parse_args(args)
  
      if len(args) != 2:
          sys.exit(not p.print_help())
  
      refbed, fastafile = args
      genome = pyfasta.Fasta(fastafile)
      edits = []
      fp = open(refbed)
      for i, row in enumerate(fp):
          s = STRLine(row)
          seq = genome[s.seqid][s.start - 1: s.end].upper()
          s.motif = get_motif(seq, len(s.motif))
          s.fix_counts(seq)
          if opts.checkvalid and not s.is_valid():
              continue
          edits.append(s)
          if i % 10000 == 0:
              print(i, "lines read", file=sys.stderr)
  
      edits = natsorted(edits, key=lambda x: (x.seqid, x.start))
      for e in edits:
          print(str(e))
docs: %prog liftover lobstr_v3.0.2_hg38_ref.bed hg38.upper.fa
  
      LiftOver CODIS/Y-STR markers.