//Count the number of target groups
List<TargetGroup> groups = new ArrayList<TargetGroup>();
for (Iterator<ProbeMakerTarget> i = proj.getTargets().iterator(); i.hasNext(); ) {
ProbeMakerTarget t = i.next();
TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType(t,TargetGroup.GROUP_TYPE);
if (tg != null) {
if (!groups.contains(tg)) {
groups.add(tg);
}
}
}
//Create a PrintStream
PrintWriter p = new PrintWriter(out);
increaseProgress();
setStatus("Writing header",0); //$NON-NLS-1$
//Print a header line
Date d = new Date();
p.println("Project exported " + DateFormat.getDateTimeInstance().format(d)); //$NON-NLS-1$
p.println(TITLE_DESCRIPTOR + VERSION);
p.println(version);
p.println(TITLE_DESCRIPTOR + NAME);
p.println(proj.getName());
increaseProgress();
setStatus("Writing targets",0); //$NON-NLS-1$
//Print the number of target groups
p.println(TITLE_DESCRIPTOR + TARGET_GROUPS);
p.println(groups.size());
//Print the target type
p.println(TITLE_DESCRIPTOR + TARGET_TYPE);
if (proj.getTargets().size() > 0) {
Sequence target = proj.getTargets().getSequenceAt(0);
p.println(target.getClass().getName());
}
else {
p.println(""); //$NON-NLS-1$
}
//Print the targets - description;sequence;type;variant;group;
p.println(TITLE_DESCRIPTOR + TARGETS);
for (Iterator<ProbeMakerTarget> i = proj.getTargets().iterator(); i.hasNext(); ) {
ProbeMakerTarget t = i.next();
setStatus(t.getID(),1);
String descStr = t.getID();
String seqStr = t instanceof SequenceView ? ((SequenceView) t).getViewSequence() : t.seqString();
String typeStr = String.valueOf(t.getType());
String varStr = ""; //$NON-NLS-1$
if (t instanceof VariantTarget) {
VariantTarget vt = (VariantTarget) t;
if (vt.getVariant() != null) {
String str = vt.getVariant().toString();
for (int v = 0; v < vt.getVariants().length; v++) {
if (vt.getVariants()[v].toString().equals(str)) {
varStr = String.valueOf(v);
//Break the loop
break;
}
}
}
}
TargetGroup tg = (TargetGroup) DesignUtils.getGroupWithType(t,TargetGroup.GROUP_TYPE);
String groupStr = String.valueOf(tg == null ? -1 : groups.indexOf(tg));
p.println(tio.getOutString(new String[] {descStr,seqStr,typeStr,varStr,groupStr}));
}
p.println(TITLE_DESCRIPTOR + LISTEND);
increaseProgress();
setStatus("Writing tags",0); //$NON-NLS-1$
//Print the tag libraries - name;mode;allowSequence;allowcomplement;
p.println(TITLE_DESCRIPTOR + LIBRARIES);
//Check for a spacer
TagLibrary[] libraries = proj.getTagSettings().getTagLibraries();
for (int i = 0, t = 0; i < libraries.length; i++, t++) {
TagLibrary l = libraries[t];
p.println(tio.getOutString(new String[] {l.getName(),
String.valueOf(l.getMode()),
String.valueOf(true),
String.valueOf(true)}));
}
p.println(TITLE_DESCRIPTOR + LISTEND);
//Print the tags of each library - id;sequence;type
for (int i = 0; i < libraries.length; i++) {
TagLibrary l = libraries[i];
p.println(TITLE_DESCRIPTOR + LIBRARY);
for (Iterator<NucleotideSequence> ti = l.iterator(); ti.hasNext(); ) {
NucleotideSequence t = ti.next();
p.println(tio.getOutString(new String[] {t.getID(),t.seqString(),String.valueOf(t.getType())}));
}
p.println(TITLE_DESCRIPTOR + LISTEND);
}
increaseProgress();
setStatus("Writing probes",0); //$NON-NLS-1$
//Make a list of probe groups
List<ProbeGroup> p_groups = new ArrayList<ProbeGroup>();
for (Iterator<Probe> i = proj.getProbes().iterator(); i.hasNext(); ) {
Probe pr = i.next();
ProbeGroup pg = (ProbeGroup) DesignUtils.getGroupWithType(pr,ProbeGroup.GROUP_TYPE);
if (pg != null) {
if (!p_groups.contains(pg)) {
p_groups.add(pg);
}
}
}
//Print the probe groups - targetGroup;groupTagLibrary;groupTagNumber;
p.println(TITLE_DESCRIPTOR + PROBE_GROUPS);
for (Iterator<ProbeGroup> i = p_groups.iterator(); i.hasNext(); ) {
ProbeGroup pg = i.next();
TargetGroup tg = pg.getTargetGroup();
int tg_no = tg == null ? -1 : groups.indexOf(tg);
int lib_no = -1;
int tag_no = -1;
String tagID = proj.getTagAllocationTable().getGroupTagID(pg);
if (tagID != null) {