project.setSettings(SettingsXMLHandler.getSettings(projE.getChild(SettingsXMLHandler.SETTINGS,ns)));
increaseProgress();
setStatus("Reading tag libraries",0); //$NON-NLS-1$
TagSettings tagSettings = getTagSettings(projE.getChild(LIBRARIES,ns));
project.setTagSettings(tagSettings);
project.getTagAllocationTable().setTagLibraries(tagSettings.getTagLibraries(),project.getSettings().getDesignParameters());
increaseProgress();
setStatus("Reading probes",0); //$NON-NLS-1$
//Read and create all probe groups
Element probeList = projE.getChild(PROBE_LIST,ns);
Map<String, ProbeGroup> probeGroups = new HashMap<String, ProbeGroup>();
for (Iterator<?> i = probeList.getChildren().iterator();i.hasNext();) {
Element probeE = (Element) i.next();
String id = probeE.getAttributeValue(ID,ns);
setStatus(id,1);
String probeName = probeE.getChildText(NAME,ns);
String typeStr = probeE.getChildText(TYPE,ns);
String rankStr = probeE.getChildText(RANK,ns);
byte type = Byte.parseByte(typeStr);
byte rank = Byte.parseByte(rankStr);
//Set the probe group, if any
ProbeGroup pg = null;
Element groupE = probeE.getChild(PROBE_GROUP,ns);
if (groupE != null) {
String groupID = groupE.getAttributeValue(ID,ns);
Attribute att = groupE.getAttribute(TARGET_GROUP,ns);
TargetGroup tg = null;
if (att!=null) {
String tGroupID = att.getValue();
tg = targetGroups.get(tGroupID);
}
pg = probeGroups.get(groupID);
if (pg != null) {
pg = new ProbeGroup(tg,groupID);
probeGroups.put(groupID, pg);
}
}
//TSSPair
Element tssPairE = probeE.getChild(TSS_PAIR,ns);
String targetID = tssPairE.getAttributeValue(TARGET_ID,ns);
ProbeMakerTarget target = null;
try {
target = project.getTargets().getSequenceByID(targetID);
}
catch (IDNotFoundException e) {
//target=null;
}
Map<String, PropertyAcceptorNucleotideSequence> tssMap = new HashMap<String, PropertyAcceptorNucleotideSequence>();
for (Iterator<?> i2 = tssPairE.getChildren(TSS,ns).iterator();i2.hasNext();) {
Element tssE = (Element) i2.next();
String key = tssE.getAttributeValue("key",ns); //$NON-NLS-1$
String tssID = tssE.getAttributeValue(ID,ns);
String tssTypeStr = tssE.getChildText(TYPE,ns);
String tssSeqStr = tssE.getChildText(SEQUENCE,ns);
String tmStr = tssE.getChildText(TM,ns);
PropertyAcceptorNucleotideSequence tss = ProbeMakerSequenceFactory.createTSS(
new SimpleNucleotideSequence(tssID, tssSeqStr, Byte.parseByte(tssTypeStr)),
targetID);
ProbeMakerPropertyUtils.setHybridizationTemp(tss,Float.parseFloat(tmStr));
addMessagesFromElement(tss,tssE.getChild("messageList",ns)); //$NON-NLS-1$
tssMap.put(key,tss);
}
PropertyAcceptorNucleotideSequence five = null;
PropertyAcceptorNucleotideSequence three = null;
five = tssMap.get(TSSPair.KEY_FIVE_PRIME);
three = tssMap.get(TSSPair.KEY_THREE_PRIME);
TSSPair tssP = ProbeMakerSequenceFactory.createTSSPair(five,three,target);
addMessagesFromElement(tssP,tssPairE.getChild("messageList",ns)); //$NON-NLS-1$
//Tags
int upstream = -1;
int downstream = -1;
Map<NucleotideSequence,SequenceDB<? extends NucleotideSequence>> tags = new LinkedHashMap<NucleotideSequence, SequenceDB<? extends NucleotideSequence>>();
Collection<?> subEList = probeE.getChild(SUB_SEQUENCES,ns).getChildren();
Element[] subEs = subEList.toArray(new Element[subEList.size()]);
for (int pos = 0;pos<subEs.length;pos++) {
if (subEs[pos].getName().equals(TSS)) {
if (upstream == -1) {
upstream = pos;
}
else if (downstream == -1) {
downstream = subEs.length - pos - 1;
}
else {
throw new IllegalArgumentException("Only two TSSs per probe allowed"); //$NON-NLS-1$
}
}
else if (subEs[pos].getName().equals(TAG_ID)) {
String tagID = subEs[pos].getAttributeValue(ID,ns);
KeyValue kv = getLibraryTag(tagSettings.getTagLibraries(),tagID);
if (kv != null) {
NucleotideSequence tag = (NucleotideSequence) kv.getKey();
SequenceDB<NucleotideSequence> lib = (SequenceDB<NucleotideSequence>) kv.getValue();
tags.put(tag,lib);
}