public void assignAffectedPerts( Residue res ){

        if(res.perts != null){
            PriorityQueue<Integer> affected = new PriorityQueue<Integer>();
            for(int b=0;b<res.perts.length;b++){
                Perturbation pert = perts[res.perts[b]];
                for(int c=0;c<pert.successors.length;c++){
                    if( !affected.contains(pert.successors[c]) ){
                        boolean inPerts = false;
                        for(int d=b;d<res.perts.length;d++){//Check if it is also in perts (it would come after pert in perts)
                            if( res.perts[d] == pert.successors[c] )
                                inPerts=true;
                        }
                        if(!inPerts)
                            affected.add(pert.successors[c]);
                    }
                }
            }
            int numAffected = affected.size();
            res.affectedPerts = new int[numAffected];
            for(int b=0;b<numAffected;b++)
                res.affectedPerts[b] = affected.poll();
        }

    }