public void writeGenotype(int type) throws IOException {
        
        buffer = (byte) (buffer >>> 2);
        
        switch (type) {
            case 0:
                break;
            case 1:
                buffer = (byte) (buffer | 0x40);
                break;
            case 2:
                buffer = (byte) (buffer | 0x80);
                break;
            case 3:
                buffer = (byte) (buffer | 0xc0);
                break;
        }
        
        placesLeftInBuffer--;
        
        if (placesLeftInBuffer == 0) {
            clearBuffer();
            placesLeftInBuffer = 4;
        }
    }