private static void ld(ProcessManager p) throws Exception{
		if(p.env().instruction().getName().equals("ld")){
			TextInput in = null;
			TextInput oin = null;
			ImageOutputStream out = null;
			int order = 0;

			try {
				in = p.textInput();
				HaplotypeSet hs = p.createHaplotypeSet(in);
				out = p.imageOutputStream();
				RSquarePlotPainter ldp = new RSquarePlotPainter(p.env(), hs);
				ldp.paintDiagram();
				if(p.env().flag("MinorAlleleDensityDistribution")) ldp.paintMinorAlleleDensity(order++);
				if(p.env().flag("SnpDensityDistribution")) ldp.paintSnpDensity(order++);

				ldp.drawLegend();
				
				if(p.env().stringPropertyExist("Other")) {
					oin = new TextInput(p.env(), p.env().stringProperty("Other"));
					HaplotypeSet ohs = p.createHaplotypeSet(oin);
					RSquarePlotPainter oldp = new RSquarePlotPainter(p.env(), ldp, ohs);
					oldp.paintCompareDiagram();
					if(p.env().flag("MinorAlleleDensityDistribution")) oldp.paintMinorAlleleDensity(order++);
					if(p.env().flag("SnpDensityDistribution")) oldp.paintSnpDensity(order++);

				}
				
				ldp.write(out);
								
			} finally { 
				if(in!=null) in.close();
				if(oin!=null) in.close();
				if(out!=null) out.close();
			}
		}
	}