public void addLocus(Locus newLocus) throws Exception {
        double tolerance = 1.0e-7;
        newLocus.setChrom(this);
        if (newLocus.getPosition()<headPos) {
            if (newLocus.getPosition()<headPos-tolerance) {
                throw new Exception("addLocus: position invalid");
            }
            else {
                newLocus.position = headPos;
            }
        }
        if (newLocus.getPosition()>tailPos) {
            if (newLocus.getPosition()>tailPos+tolerance) {
                throw new Exception("addLocus: position invalid");
            }
            else {
                newLocus.position = tailPos;
            }
        }
        if (locus.isEmpty()) locus.add(newLocus);
        else {
            int index = 0;
            Locus loc = locus.get(index);
            while (index<locus.size() && 
                    locus.get(index).getPosition()<= newLocus.getPosition()) {
                index++;
            }
            locus.add(index, newLocus);
        }
    } //addLocus