I found a couple of good answers like [here][1] for example, but I do not manage to adapt them and make them work... 

What i am trying to do: take the input, create new output with same fields, add a new field with values calculated from another field.
For the moment, I managed to get the new values for the new field in a list:

    from collections import Counter as counter
    
    layer = qgis.utils.iface.activeLayer()
    features = layer.getFeatures()
    
    # find the index of the 'relict_id' field.
    idx = layer.fieldNameIndex('RELICT_ID')
    
    relict_id = []
    for feat in features:
        attrs = feat.attributes()
        relict_id.append(attrs[idx])
    
    relict_id_new = [x for x in relict_id]
    
    c = counter(relict_id)
    idx = 0
    while idx in range(len(relict_id)):
        rel_id = relict_id[idx]  
        if c[rel_id] != 1:
            for x in range(c[rel_id]):
                relict_id_new[idx+x] = '{}_{}'.format(relict_id[idx],x)
            idx += c[rel_id]
        else:
            idx +=1

I would like now to adapt this [answer][1], but all I get is a bunch of errors. I tried to get rid off *Processings* since it does not seem to work for me (QGIS 2.18.2). I am not understanding pretty well the implication of the processes, I do not know if it is the good way to do it and what are the problems.

  [1]: https://gis.stackexchange.com/questions/208372/creating-new-layer-from-another-one-and-adding-new-fields-with-qgis-processing-p