package org.bbop.apollo.sequence.search.blast;

import org.bbop.apollo.sequence.search.AlignmentParsingException;

public class TabDelimittedAlignment extends BlastAlignment {

    private final static int EXPECTED_NUM_FIELDS = 12;
    private final static String DELIMITER = "\t";
    
    public TabDelimittedAlignment(String tabbedAlignment) throws AlignmentParsingException {
        String []fields = tabbedAlignment.split(DELIMITER);
        if (fields.length != EXPECTED_NUM_FIELDS) {
            throw new AlignmentParsingException("Incorrect number of fields: found " + fields.length + " but expected " + EXPECTED_NUM_FIELDS);
        }
        String queryId = fields[0];
        String subjectId = fields[1];
        double percentId = Double.parseDouble(fields[2]);
        int alignmentLength = Integer.parseInt(fields[3]);
        int numMismatches = Integer.parseInt(fields[4]);
        int numGaps = Integer.parseInt(fields[5]);
        int queryStart = Integer.parseInt(fields[6]);
        int queryEnd = Integer.parseInt(fields[7]);
        int subjectStart = Integer.parseInt(fields[8]);
        int subjectEnd = Integer.parseInt(fields[9]);
        double eValue = Double.parseDouble(fields[10]);
        double bitscore = Double.parseDouble(fields[11]);
        init(queryId, subjectId, percentId, alignmentLength, numMismatches, numGaps,
                queryStart, queryEnd, subjectStart, subjectEnd, eValue, bitscore);
    }
    
}

@@ -1150,24 +1150,346 @@
 fields%5B9%5D);%0A
+        if(subjectEnd%3CsubjectStart) %7B%0A            int swap;%0A            swap=subjectStart;%0A            subjectStart=subjectEnd;%0A            subjectEnd=swap;%0A        %7D%0A        if(queryEnd%3CqueryStart) %7B%0A            int swap;%0A            swap=queryStart;%0A            queryStart=queryEnd;%0A            queryEnd=swap;%0A        %7D%0A
         doub

Make start always less than end for the BLAT results