	private void writeSampleFile(Writer sampleWriter) throws IOException
	{
		StringBuilder sb = new StringBuilder();
		sb.append("ID_1");
		sb.append(SEPARATOR);
		sb.append("ID_2");
		sb.append(SEPARATOR);
		sb.append("missing");
		List<String> colNames = new ArrayList<String>();
		List<String> dataTypes = new ArrayList<String>();
		for (SampleAnnotation annotation : genotypeData.getSampleAnnotations())
		{
			if (annotation.getSampleAnnotationType() == SampleAnnotationType.COVARIATE)
			{
				switch (annotation.getType())
				{
					case INTEGER:
						colNames.add(annotation.getId());
						dataTypes.add("D");
						break;
					case FLOAT:
						colNames.add(annotation.getId());
						dataTypes.add("C");
					default:
						LOG.warn("Unsupported covariate datatype [" + annotation.getType() + "]");
				}
			}
			else if (annotation.getSampleAnnotationType() == SampleAnnotationType.PHENOTYPE)
			{
				switch (annotation.getType())
				{
					case BOOLEAN:
						colNames.add(annotation.getId());
						dataTypes.add("B");
						break;
					case FLOAT:
						colNames.add(annotation.getId());
						dataTypes.add("P");
					default:
						LOG.warn("Unsupported phenotype datatype [" + annotation.getType() + "]");
				}
			}
			else
			{
				LOG.warn("'OTHER' sample annotation type not supported by impute2");
			}
		}
		for (String colName : colNames)
		{
			sb.append(SEPARATOR);
			sb.append(colName);
		}
		sb.append(LINE_ENDING);
		sb.append("0");
		sb.append(SEPARATOR);
		sb.append("0");
		sb.append(SEPARATOR);
		sb.append("0");
		for (String dataType : dataTypes)
		{
			sb.append(SEPARATOR);
			sb.append(dataType);
		}
		sb.append(LINE_ENDING);
		sampleWriter.write(sb.toString());
		for (Sample sample : genotypeData.getSamples())
		{
			sb = new StringBuilder();
			sb.append(sample.getFamilyId() == null ? "NA" : sample.getFamilyId());
			sb.append(SEPARATOR);
			sb.append(sample.getId() == null ? "NA" : sample.getId());
			sb.append(SEPARATOR);
			sb.append(getValue("missing", sample, "0"));
			for (String colName : colNames)
			{
				sb.append(SEPARATOR);
				sb.append(getValue(colName, sample, "NA"));
			}
			sb.append(LINE_ENDING);
			sampleWriter.write(sb.toString());
		}
	}

	private void writeSampleFile(Writer sampleWriter) throws IOException
	{
		StringBuilder sb = new StringBuilder();
		sb.append("ID_1");
		sb.append(SEPARATOR);
		sb.append("ID_2");
		sb.append(SEPARATOR);
		sb.append("missing");
		List<String> colNames = new ArrayList<String>();
		List<String> dataTypes = new ArrayList<String>();
		for (SampleAnnotation annotation : genotypeData.getSampleAnnotations())
		{
			if (annotation.getSampleAnnotationType() == SampleAnnotationType.COVARIATE)
			{
				switch (annotation.getType())
				{
					case INTEGER:
						colNames.add(annotation.getId());
						dataTypes.add("D");
						break;
					case FLOAT:
						colNames.add(annotation.getId());
						dataTypes.add("C");
						break;
					default:
						LOG.warn("Unsupported covariate datatype [" + annotation.getType() + "]");
						break;
				}
			}
			else if (annotation.getSampleAnnotationType() == SampleAnnotationType.PHENOTYPE)
			{
				switch (annotation.getType())
				{
					case BOOLEAN:
						colNames.add(annotation.getId());
						dataTypes.add("B");
						break;
					case FLOAT:
						colNames.add(annotation.getId());
						dataTypes.add("P");
					default:
						LOG.warn("Unsupported phenotype datatype [" + annotation.getType() + "]");
				}
			}
			else
			{
				LOG.warn("'OTHER' sample annotation type not supported by impute2");
			}
		}
		for (String colName : colNames)
		{
			sb.append(SEPARATOR);
			sb.append(colName);
		}
		sb.append(LINE_ENDING);
		sb.append("0");
		sb.append(SEPARATOR);
		sb.append("0");
		sb.append(SEPARATOR);
		sb.append("0");
		for (String dataType : dataTypes)
		{
			sb.append(SEPARATOR);
			sb.append(dataType);
		}
		sb.append(LINE_ENDING);
		sampleWriter.write(sb.toString());
		for (Sample sample : genotypeData.getSamples())
		{
			sb = new StringBuilder();
			sb.append(sample.getFamilyId() == null ? "NA" : sample.getFamilyId());
			sb.append(SEPARATOR);
			sb.append(sample.getId() == null ? "NA" : sample.getId());
			sb.append(SEPARATOR);
			sb.append(getValue("missing", sample, "0"));
			for (String colName : colNames)
			{
				sb.append(SEPARATOR);
				sb.append(getValue(colName, sample, "NA"));
			}
			sb.append(LINE_ENDING);
			sampleWriter.write(sb.toString());
		}
	}
