nodes: 0, module; 1, function_definition; 2, function_name:expectedLabelPosition; 3, parameters; 4, block; 5, identifier:peptide; 6, identifier:labelStateInfo; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, expression_statement; 13, for_statement; 14, if_statement; 15, for_statement; 16, return_statement; 17, identifier:sequence; 18, None; 19, identifier:modPositions; 20, None; 21, comment:"""Returns a modification description of a certain label state of a peptide.
  
      :param peptide: Peptide sequence used to calculat the expected label state
          modifications
      :param labelStateInfo: An entry of :attr:`LabelDescriptor.labels` that
          describes a label state
      :param sequence: unmodified amino acid sequence of :var:`peptide`, if None
          it is generated by :func:`maspy.peptidemethods.removeModifications()`
      :param modPositions: dictionary describing the modification state of
          "peptide", if None it is generated by
          :func:`maspy.peptidemethods.returnModPositions()`
  
      :returns: {sequence position: sorted list of expected label modifications
                    on that position, ...
                 }
      """; 22, comparison_operator:modPositions is None; 23, block; 24, comparison_operator:sequence is None; 25, block; 26, assignment; 27, pattern_list; 28, call; 29, block; 30, comparison_operator:labelStateInfo['excludingModifications'] is not None; 31, block; 32, identifier:sequencePosition; 33, call; 34, block; 35, identifier:currLabelMods; 36, identifier:modPositions; 37, None; 38, expression_statement; 39, identifier:sequence; 40, None; 41, expression_statement; 42, identifier:currLabelMods; 43, call; 44, identifier:labelPosition; 45, identifier:labelSymbols; 46, identifier:viewitems; 47, argument_list; 48, expression_statement; 49, if_statement; 50, subscript; 51, None; 52, for_statement; 53, identifier:list; 54, argument_list; 55, expression_statement; 56, assignment; 57, assignment; 58, identifier:dict; 59, argument_list; 60, subscript; 61, assignment; 62, comparison_operator:labelSymbols == ['']; 63, block; 64, elif_clause; 65, else_clause; 66, identifier:labelStateInfo; 67, string; 68, pattern_list; 69, call; 70, block; 71, call; 72, assignment; 73, identifier:modPositions; 74, call; 75, identifier:sequence; 76, call; 77, identifier:labelStateInfo; 78, string; 79, identifier:labelSymbols; 80, call; 81, identifier:labelSymbols; 82, list; 83, pass_statement; 84, comparison_operator:labelPosition == 'nTerm'; 85, block; 86, block; 87, string_content:excludingModifications; 88, identifier:excludingMod; 89, identifier:excludedLabelSymbol; 90, identifier:viewitems; 91, argument_list; 92, if_statement; 93, for_statement; 94, identifier:viewkeys; 95, argument_list; 96, subscript; 97, call; 98, attribute; 99, argument_list; 100, attribute; 101, argument_list; 102, string_content:aminoAcidLabels; 103, attribute; 104, argument_list; 105, string; 106, identifier:labelPosition; 107, string; 108, expression_statement; 109, expression_statement; 110, for_statement; 111, subscript; 112, comparison_operator:excludingMod not in modPositions; 113, block; 114, identifier:excludingModPos; 115, subscript; 116, block; 117, identifier:currLabelMods; 118, identifier:currLabelMods; 119, identifier:sequencePosition; 120, identifier:sorted; 121, argument_list; 122, attribute; 123, identifier:returnModPositions; 124, identifier:peptide; 125, keyword_argument; 126, attribute; 127, identifier:removeModifications; 128, identifier:peptide; 129, identifier:aux; 130, identifier:toList; 131, identifier:labelSymbols; 132, string_content:nTerm; 133, call; 134, call; 135, identifier:sequencePosition; 136, call; 137, block; 138, identifier:labelStateInfo; 139, string; 140, identifier:excludingMod; 141, identifier:modPositions; 142, continue_statement; 143, identifier:modPositions; 144, identifier:excludingMod; 145, if_statement; 146, if_statement; 147, if_statement; 148, subscript; 149, identifier:maspy; 150, identifier:peptidemethods; 151, identifier:indexStart; 152, integer:0; 153, identifier:maspy; 154, identifier:peptidemethods; 155, attribute; 156, argument_list; 157, attribute; 158, argument_list; 159, attribute; 160, argument_list; 161, expression_statement; 162, expression_statement; 163, string_content:excludingModifications; 164, comparison_operator:excludingModPos not in currLabelMods; 165, block; 166, comparison_operator:excludedLabelSymbol not in currLabelMods[excludingModPos]; 167, block; 168, comparison_operator:len(currLabelMods[excludingModPos]) == 1; 169, block; 170, else_clause; 171, identifier:currLabelMods; 172, identifier:sequencePosition; 173, identifier:currLabelMods; 174, identifier:setdefault; 175, integer:0; 176, call; 177, subscript; 178, identifier:extend; 179, identifier:labelSymbols; 180, identifier:aux; 181, identifier:findAllSubstrings; 182, identifier:sequence; 183, identifier:labelPosition; 184, call; 185, call; 186, identifier:excludingModPos; 187, identifier:currLabelMods; 188, continue_statement; 189, identifier:excludedLabelSymbol; 190, subscript; 191, continue_statement; 192, call; 193, integer:1; 194, delete_statement; 195, block; 196, identifier:list; 197, argument_list; 198, identifier:currLabelMods; 199, integer:0; 200, attribute; 201, argument_list; 202, attribute; 203, argument_list; 204, identifier:currLabelMods; 205, identifier:excludingModPos; 206, identifier:len; 207, argument_list; 208, parenthesized_expression; 209, expression_statement; 210, expression_statement; 211, identifier:currLabelMods; 212, identifier:setdefault; 213, identifier:sequencePosition; 214, call; 215, subscript; 216, identifier:extend; 217, identifier:labelSymbols; 218, subscript; 219, subscript; 220, assignment; 221, call; 222, identifier:list; 223, argument_list; 224, identifier:currLabelMods; 225, identifier:sequencePosition; 226, identifier:currLabelMods; 227, identifier:excludingModPos; 228, identifier:currLabelMods; 229, identifier:excludingModPos; 230, identifier:excludedModIndex; 231, call; 232, attribute; 233, argument_list; 234, attribute; 235, argument_list; 236, subscript; 237, identifier:pop; 238, identifier:excludedModIndex; 239, subscript; 240, identifier:index; 241, identifier:excludedLabelSymbol; 242, identifier:currLabelMods; 243, identifier:excludingModPos; 244, identifier:currLabelMods; 245, identifier:excludingModPos
code: def expectedLabelPosition(peptide, labelStateInfo, sequence=None,
                            modPositions=None):
      """Returns a modification description of a certain label state of a peptide.
  
      :param peptide: Peptide sequence used to calculat the expected label state
          modifications
      :param labelStateInfo: An entry of :attr:`LabelDescriptor.labels` that
          describes a label state
      :param sequence: unmodified amino acid sequence of :var:`peptide`, if None
          it is generated by :func:`maspy.peptidemethods.removeModifications()`
      :param modPositions: dictionary describing the modification state of
          "peptide", if None it is generated by
          :func:`maspy.peptidemethods.returnModPositions()`
  
      :returns: {sequence position: sorted list of expected label modifications
                    on that position, ...
                 }
      """
      if modPositions is None:
          modPositions = maspy.peptidemethods.returnModPositions(peptide,
                                                                 indexStart=0
                                                                 )
      if sequence is None:
          sequence = maspy.peptidemethods.removeModifications(peptide)
  
      currLabelMods = dict()
      for labelPosition, labelSymbols in viewitems(labelStateInfo['aminoAcidLabels']):
          labelSymbols = aux.toList(labelSymbols)
          if labelSymbols == ['']:
              pass
          elif labelPosition == 'nTerm':
              currLabelMods.setdefault(0, list())
              currLabelMods[0].extend(labelSymbols)
          else:
              for sequencePosition in aux.findAllSubstrings(sequence,
                                                            labelPosition):
                  currLabelMods.setdefault(sequencePosition, list())
                  currLabelMods[sequencePosition].extend(labelSymbols)
  
      if labelStateInfo['excludingModifications'] is not None:
          for excludingMod, excludedLabelSymbol in viewitems(labelStateInfo['excludingModifications']):
              if excludingMod not in modPositions:
                  continue
              for excludingModPos in modPositions[excludingMod]:
                  if excludingModPos not in currLabelMods:
                      continue
                  if excludedLabelSymbol not in currLabelMods[excludingModPos]:
                      continue
                  if len(currLabelMods[excludingModPos]) == 1:
                      del(currLabelMods[excludingModPos])
                  else:
                      excludedModIndex = currLabelMods[excludingModPos].index(excludedLabelSymbol)
                      currLabelMods[excludingModPos].pop(excludedModIndex)
  
      for sequencePosition in list(viewkeys(currLabelMods)):
          currLabelMods[sequencePosition] = sorted(currLabelMods[sequencePosition])
      return currLabelMods