nodes: 0, module; 1, function_definition; 2, function_name:generate_psms_quanted; 3, parameters; 4, block; 5, identifier:quantdb; 6, identifier:tsvfn; 7, identifier:isob_header; 8, identifier:oldheader; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, identifier:isobaric; 16, False; 17, identifier:precursor; 18, False; 19, comment:"""Takes dbfn and connects, gets quants for each line in tsvfn, sorts
      them in line by using keys in quantheader list."""; 20, assignment; 21, assignment; 22, pattern_list; 23, call; 24, block; 25, pattern_list; 26, call; 27, identifier:quant; 28, call; 29, identifier:rownr; 30, identifier:psm; 31, identifier:enumerate; 32, argument_list; 33, expression_statement; 34, if_statement; 35, if_statement; 36, expression_statement; 37, identifier:allquants; 38, identifier:sqlfields; 39, attribute; 40, argument_list; 41, identifier:next; 42, argument_list; 43, call; 44, assignment; 45, identifier:precursor; 46, block; 47, identifier:isobaric; 48, block; 49, else_clause; 50, yield; 51, identifier:quantdb; 52, identifier:select_all_psm_quants; 53, identifier:isobaric; 54, identifier:precursor; 55, identifier:allquants; 56, attribute; 57, argument_list; 58, identifier:outpsm; 59, dictionary_comprehension; 60, expression_statement; 61, if_statement; 62, expression_statement; 63, expression_statement; 64, while_statement; 65, expression_statement; 66, block; 67, identifier:outpsm; 68, identifier:readers; 69, identifier:generate_tsv_psms; 70, identifier:tsvfn; 71, identifier:oldheader; 72, pair; 73, for_in_clause; 74, assignment; 75, comparison_operator:pquant is None; 76, block; 77, call; 78, assignment; 79, comparison_operator:quant[0] == rownr; 80, block; 81, call; 82, try_statement; 83, identifier:x; 84, identifier:y; 85, pattern_list; 86, call; 87, identifier:pquant; 88, subscript; 89, identifier:pquant; 90, None; 91, expression_statement; 92, attribute; 93, argument_list; 94, identifier:isoquants; 95, dictionary; 96, subscript; 97, identifier:rownr; 98, expression_statement; 99, try_statement; 100, attribute; 101, argument_list; 102, block; 103, except_clause; 104, identifier:x; 105, identifier:y; 106, attribute; 107, argument_list; 108, identifier:quant; 109, subscript; 110, assignment; 111, identifier:outpsm; 112, identifier:update; 113, dictionary; 114, identifier:quant; 115, integer:0; 116, call; 117, block; 118, except_clause; 119, identifier:outpsm; 120, identifier:update; 121, call; 122, expression_statement; 123, identifier:StopIteration; 124, comment:# last PSM, needs explicit yield/break or it will not be yielded; 125, block; 126, identifier:psm; 127, identifier:items; 128, identifier:sqlfields; 129, string; 130, identifier:pquant; 131, string; 132, pair; 133, attribute; 134, argument_list; 135, expression_statement; 136, identifier:StopIteration; 137, comment:# last PSM, break from while loop or it is not yielded at all; 138, block; 139, identifier:get_quant_NAs; 140, argument_list; 141, assignment; 142, expression_statement; 143, break_statement; 144, string_content:precursor; 145, string_content:NA; 146, attribute; 147, call; 148, identifier:isoquants; 149, identifier:update; 150, dictionary; 151, assignment; 152, break_statement; 153, identifier:isoquants; 154, identifier:isob_header; 155, identifier:quant; 156, call; 157, yield; 158, identifier:mzidtsvdata; 159, identifier:HEADER_PRECURSOR_QUANT; 160, identifier:str; 161, argument_list; 162, pair; 163, identifier:quant; 164, call; 165, identifier:next; 166, argument_list; 167, identifier:outpsm; 168, identifier:pquant; 169, subscript; 170, call; 171, identifier:next; 172, argument_list; 173, identifier:allquants; 174, identifier:quant; 175, subscript; 176, identifier:str; 177, argument_list; 178, identifier:allquants; 179, identifier:sqlfields; 180, string; 181, subscript; 182, string_content:isochan; 183, identifier:quant; 184, subscript; 185, identifier:sqlfields; 186, string; 187, string_content:isoquant
code: def generate_psms_quanted(quantdb, tsvfn, isob_header, oldheader,
                            isobaric=False, precursor=False):
      """Takes dbfn and connects, gets quants for each line in tsvfn, sorts
      them in line by using keys in quantheader list."""
      allquants, sqlfields = quantdb.select_all_psm_quants(isobaric, precursor)
      quant = next(allquants)
      for rownr, psm in enumerate(readers.generate_tsv_psms(tsvfn, oldheader)):
          outpsm = {x: y for x, y in psm.items()}
          if precursor:
              pquant = quant[sqlfields['precursor']]
              if pquant is None:
                  pquant = 'NA'
              outpsm.update({mzidtsvdata.HEADER_PRECURSOR_QUANT: str(pquant)})
          if isobaric:
              isoquants = {}
              while quant[0] == rownr:
                  isoquants.update({quant[sqlfields['isochan']]:
                                    str(quant[sqlfields['isoquant']])})
                  try:
                      quant = next(allquants)
                  except StopIteration:
                      # last PSM, break from while loop or it is not yielded at all
                      break
              outpsm.update(get_quant_NAs(isoquants, isob_header))
          else:
              try:
                  quant = next(allquants)
              except StopIteration:
                  # last PSM, needs explicit yield/break or it will not be yielded
                  yield outpsm
                  break
          yield outpsm