+ String outputfile = rf.formatSequences(ioformat, al, true);
+ System.out.println("Output file in '" + ioformat + "':\n"
+ + outputfile + "\n<<EOF\n");
+ // test for consistency in io
+ AlignmentI al_input = new AppletFormatAdapter().readFile(outputfile,
+ AppletFormatAdapter.PASTE, ioformat);
+ assertNotNull("Couldn't parse reimported alignment data.", al_input);
+
+ String identifyoutput = new IdentifyFile().identify(outputfile,
+ AppletFormatAdapter.PASTE);
+ assertNotNull("Identify routine failed for outputformat " + ioformat,
+ identifyoutput);
+ assertTrue(
+ "Identify routine could not recognise output generated by '"
+ + ioformat + "' writer",
+ ioformat.equals(identifyoutput));
+ testAlignmentEquivalence(al, al_input, false);
+ int numaliannot = 0, numsqswithali = 0;
+ for (AlignmentAnnotation ala : al_input.getAlignmentAnnotation())
+ {
+ if (ala.sequenceRef == null)
+ {
+ numaliannot++;
+ }
+ else
+ {
+ numsqswithali++;
+ }
+ }
+ if (naliannot > -1)
+ {
+ assertEquals("Number of alignment annotations", naliannot,
+ numaliannot);
+ }
+
+ assertTrue(
+ "Number of sequence associated annotations wasn't at least "
+ + nminseqann, numsqswithali >= nminseqann);
+
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ assertTrue("Couln't format the alignment for output file.", false);
+ }
+ }
+
+ /**
+ * assert alignment equivalence
+ *
+ * @param al
+ * 'original'
+ * @param al_input
+ * 'secondary' or generated alignment from some datapreserving
+ * transformation
+ * @param ignoreFeatures
+ * when true, differences in sequence feature annotation are ignored
+ */
+ public static void testAlignmentEquivalence(AlignmentI al,
+ AlignmentI al_input, boolean ignoreFeatures)
+ {
+ assertNotNull("Original alignment was null", al);
+ assertNotNull("Generated alignment was null", al_input);
+
+ assertTrue("Alignment dimension mismatch: original: " + al.getHeight()
+ + "x" + al.getWidth() + ", generated: " + al_input.getHeight()
+ + "x" + al_input.getWidth(),
+ al.getHeight() == al_input.getHeight()
+ && al.getWidth() == al_input.getWidth());