nodes: 0, module; 1, function_definition; 2, function_name:posmap; 3, parameters; 4, block; 5, identifier:args; 6, expression_statement; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, expression_statement; 11, comment:# fasta; 12, expression_statement; 13, expression_statement; 14, if_statement; 15, comment:# sizes; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, expression_statement; 20, comment:# gaps.bed; 21, expression_statement; 22, if_statement; 23, comment:# reads frgscf posmap; 24, expression_statement; 25, if_statement; 26, comment:# reads bed; 27, expression_statement; 28, if_statement; 29, comment:# reads bedpe; 30, expression_statement; 31, expression_statement; 32, if_statement; 33, comment:# base coverage; 34, expression_statement; 35, expression_statement; 36, comment:"""
      %prog posmap frgscf.sorted scf.fasta scfID
  
      Perform QC on the selected scfID, generate multiple BED files for plotting.
      """; 37, assignment; 38, assignment; 39, comparison_operator:len(args) != 3; 40, block; 41, assignment; 42, assignment; 43, assignment; 44, not_operator; 45, block; 46, assignment; 47, assignment; 48, assignment; 49, call; 50, assignment; 51, not_operator; 52, block; 53, assignment; 54, not_operator; 55, block; 56, assignment; 57, not_operator; 58, block; 59, assignment; 60, assignment; 61, not_operator; 62, block; 63, call; 64, call; 65, identifier:p; 66, call; 67, pattern_list; 68, call; 69, call; 70, integer:3; 71, expression_statement; 72, pattern_list; 73, identifier:args; 74, identifier:cmd; 75, call; 76, identifier:scffastafile; 77, binary_operator:scf + ".fasta"; 78, call; 79, expression_statement; 80, identifier:sizesfile; 81, binary_operator:scffastafile + ".sizes"; 82, identifier:sizes; 83, attribute; 84, identifier:scfsize; 85, subscript; 86, attribute; 87, argument_list; 88, identifier:gapsbedfile; 89, binary_operator:scf + ".gaps.bed"; 90, call; 91, expression_statement; 92, expression_statement; 93, identifier:posmapfile; 94, binary_operator:scf + ".posmap"; 95, call; 96, expression_statement; 97, expression_statement; 98, identifier:bedfile; 99, binary_operator:scf + ".bed"; 100, call; 101, expression_statement; 102, expression_statement; 103, identifier:bedpefile; 104, binary_operator:scf + ".bedpe"; 105, identifier:pairsbedfile; 106, binary_operator:scf + ".pairs.bed"; 107, parenthesized_expression; 108, expression_statement; 109, identifier:Coverage; 110, argument_list; 111, identifier:Coverage; 112, argument_list; 113, identifier:OptionParser; 114, argument_list; 115, identifier:opts; 116, identifier:args; 117, attribute; 118, argument_list; 119, identifier:len; 120, argument_list; 121, call; 122, identifier:frgscffile; 123, identifier:fastafile; 124, identifier:scf; 125, attribute; 126, argument_list; 127, identifier:scf; 128, string:".fasta"; 129, attribute; 130, argument_list; 131, call; 132, identifier:scffastafile; 133, string:".sizes"; 134, call; 135, identifier:mapping; 136, identifier:sizes; 137, identifier:scf; 138, identifier:logging; 139, identifier:debug; 140, call; 141, identifier:scf; 142, string:".gaps.bed"; 143, attribute; 144, argument_list; 145, assignment; 146, call; 147, identifier:scf; 148, string:".posmap"; 149, attribute; 150, argument_list; 151, assignment; 152, call; 153, identifier:scf; 154, string:".bed"; 155, attribute; 156, argument_list; 157, assignment; 158, call; 159, identifier:scf; 160, string:".bedpe"; 161, identifier:scf; 162, string:".pairs.bed"; 163, boolean_operator; 164, call; 165, identifier:bedfile; 166, identifier:sizesfile; 167, identifier:pairsbedfile; 168, identifier:sizesfile; 169, attribute; 170, identifier:p; 171, identifier:parse_args; 172, identifier:args; 173, identifier:args; 174, attribute; 175, argument_list; 176, string:"faOneRecord {0} {1}"; 177, identifier:format; 178, identifier:fastafile; 179, identifier:scf; 180, identifier:op; 181, identifier:exists; 182, identifier:scffastafile; 183, identifier:sh; 184, argument_list; 185, identifier:Sizes; 186, argument_list; 187, attribute; 188, argument_list; 189, identifier:op; 190, identifier:exists; 191, identifier:gapsbedfile; 192, identifier:args; 193, list; 194, identifier:gaps; 195, argument_list; 196, identifier:op; 197, identifier:exists; 198, identifier:posmapfile; 199, identifier:args; 200, list; 201, identifier:query; 202, argument_list; 203, identifier:op; 204, identifier:exists; 205, identifier:bedfile; 206, identifier:args; 207, list; 208, identifier:bed; 209, argument_list; 210, call; 211, call; 212, identifier:bed_to_bedpe; 213, argument_list; 214, identifier:posmap; 215, identifier:__doc__; 216, identifier:sys; 217, identifier:exit; 218, call; 219, identifier:cmd; 220, keyword_argument; 221, identifier:scffastafile; 222, string:"`{0}` has length of {1}."; 223, identifier:format; 224, identifier:scf; 225, identifier:scfsize; 226, identifier:scffastafile; 227, string:"--bed"; 228, string:"--mingap=100"; 229, identifier:args; 230, identifier:frgscffile; 231, identifier:scf; 232, identifier:args; 233, identifier:posmapfile; 234, identifier:args; 235, attribute; 236, argument_list; 237, attribute; 238, argument_list; 239, identifier:bedfile; 240, identifier:bedpefile; 241, keyword_argument; 242, keyword_argument; 243, attribute; 244, argument_list; 245, identifier:outfile; 246, identifier:scffastafile; 247, identifier:op; 248, identifier:exists; 249, identifier:bedpefile; 250, identifier:op; 251, identifier:exists; 252, identifier:pairsbedfile; 253, identifier:pairsbedfile; 254, identifier:pairsbedfile; 255, identifier:ca; 256, True; 257, identifier:p; 258, identifier:print_help
code: def posmap(args):
      """
      %prog posmap frgscf.sorted scf.fasta scfID
  
      Perform QC on the selected scfID, generate multiple BED files for plotting.
      """
      p = OptionParser(posmap.__doc__)
  
      opts, args = p.parse_args(args)
  
      if len(args) != 3:
          sys.exit(p.print_help())
  
      frgscffile, fastafile, scf = args
  
      # fasta
      cmd = "faOneRecord {0} {1}".format(fastafile, scf)
      scffastafile = scf + ".fasta"
      if not op.exists(scffastafile):
          sh(cmd, outfile=scffastafile)
  
      # sizes
      sizesfile = scffastafile + ".sizes"
      sizes = Sizes(scffastafile).mapping
      scfsize = sizes[scf]
      logging.debug("`{0}` has length of {1}.".format(scf, scfsize))
  
      # gaps.bed
      gapsbedfile = scf + ".gaps.bed"
      if not op.exists(gapsbedfile):
          args = [scffastafile, "--bed", "--mingap=100"]
          gaps(args)
  
      # reads frgscf posmap
      posmapfile = scf + ".posmap"
      if not op.exists(posmapfile):
          args = [frgscffile, scf]
          query(args)
  
      # reads bed
      bedfile = scf + ".bed"
      if not op.exists(bedfile):
          args = [posmapfile]
          bed(args)
  
      # reads bedpe
      bedpefile = scf + ".bedpe"
      pairsbedfile = scf + ".pairs.bed"
      if not (op.exists(bedpefile) and op.exists(pairsbedfile)):
          bed_to_bedpe(bedfile, bedpefile, pairsbedfile=pairsbedfile, ca=True)
  
      # base coverage
      Coverage(bedfile, sizesfile)
      Coverage(pairsbedfile, sizesfile)