001/*
002 *                    BioJava development code
003 *
004 * This code may be freely distributed and modified under the
005 * terms of the GNU Lesser General Public Licence.  This should
006 * be distributed with the code.  If you do not have a copy,
007 * see:
008 *
009 *      http://www.gnu.org/copyleft/lesser.html
010 *
011 * Copyright for this code is held jointly by the individual
012 * authors.  These should be listed in @author doc comments.
013 *
014 * For more information on the BioJava project and its aims,
015 * or to join the biojava-l mailing list, visit the home page
016 * at:
017 *
018 *      http://www.biojava.org/
019 *
020 */
021
022package org.biojava.bio.seq.io;
023
024import java.util.ArrayList;
025import java.util.Comparator;
026import java.util.List;
027
028/**
029 * <p><code>GenEmblPropertyComparator</code> compares Genbank/EMBL
030 * file format tags by the order in which they should appear in their
031 * respective formats.</p>
032 *
033 * <p>EMBL tags sort before Genbank tags. This is arbitrary. Given the
034 * subtle differences in the values accompanying equivalent tags in
035 * these formats the two sets shouldn't be mixed anyway.</p>
036 *
037 * <p>Any tags which belong to neither set sort before anything
038 * else.<p>
039 *
040 * @author Keith James
041 * @deprecated Use org.biojavax.bio.seq.io framework instead
042 */
043public final class GenEmblPropertyComparator implements Comparator
044{
045    public static final Comparator INSTANCE = new GenEmblPropertyComparator();
046
047    private List tagOrder;
048
049    private GenEmblPropertyComparator()
050    {
051        tagOrder = new ArrayList();
052        tagOrder.add(EmblLikeFormat.ID_TAG);
053        tagOrder.add(EmblLikeFormat.ACCESSION_TAG);
054        tagOrder.add(EmblLikeFormat.VERSION_TAG);
055        tagOrder.add(EmblLikeFormat.DATE_TAG);
056        tagOrder.add(EmblLikeFormat.DEFINITION_TAG);
057        tagOrder.add(EmblLikeFormat.KEYWORDS_TAG);
058        tagOrder.add(EmblLikeFormat.SOURCE_TAG);
059        tagOrder.add(EmblLikeFormat.ORGANISM_TAG);
060        /*tagOrder.add(EmblLikeFormat.REFERENCE_TAG);
061        tagOrder.add(EmblLikeFormat.COORDINATE_TAG);
062        tagOrder.add(EmblLikeFormat.REF_ACCESSION_TAG);
063        tagOrder.add(EmblLikeFormat.AUTHORS_TAG);
064        tagOrder.add(EmblLikeFormat.TITLE_TAG);
065        tagOrder.add(EmblLikeFormat.JOURNAL_TAG);*/
066        tagOrder.add(ReferenceAnnotation.class);
067        tagOrder.add(EmblLikeFormat.DR_TAG);//lorna:added 21.08.03
068        tagOrder.add(EmblLikeFormat.COORDINATE_TAG);
069        tagOrder.add(EmblLikeFormat.REF_ACCESSION_TAG);
070        tagOrder.add(EmblLikeFormat.AUTHORS_TAG);
071        tagOrder.add(EmblLikeFormat.TITLE_TAG);
072        tagOrder.add(EmblLikeFormat.JOURNAL_TAG);
073        tagOrder.add(EmblLikeFormat.REF_XREF_TAG);
074        tagOrder.add(EmblLikeFormat.COMMENT_TAG);
075        tagOrder.add(EmblLikeFormat.FEATURE_TAG);
076
077        tagOrder.add(GenbankFormat.LOCUS_TAG);
078        tagOrder.add(GenbankFormat.SIZE_TAG);
079        tagOrder.add(GenbankFormat.STRAND_NUMBER_TAG);
080        tagOrder.add(GenbankFormat.TYPE_TAG);
081        tagOrder.add(GenbankFormat.CIRCULAR_TAG);
082        tagOrder.add(GenbankFormat.DIVISION_TAG);
083        tagOrder.add(GenbankFormat.DATE_TAG);
084        tagOrder.add(GenbankFormat.DEFINITION_TAG);
085        tagOrder.add(GenbankFormat.ACCESSION_TAG);
086        tagOrder.add(GenbankFormat.VERSION_TAG);
087        tagOrder.add(GenbankFormat.GI_TAG);
088        tagOrder.add(GenbankFormat.KEYWORDS_TAG);
089        tagOrder.add(GenbankFormat.SOURCE_TAG);
090        tagOrder.add(GenbankFormat.ORGANISM_TAG);
091        tagOrder.add(GenbankFormat.REFERENCE_TAG);
092        tagOrder.add(GenbankFormat.AUTHORS_TAG);
093        tagOrder.add(GenbankFormat.TITLE_TAG);
094        tagOrder.add(GenbankFormat.JOURNAL_TAG);
095        tagOrder.add(GenbankFormat.PUBMED_TAG);
096        tagOrder.add(GenbankFormat.MEDLINE_TAG);
097        tagOrder.add(GenbankFormat.COMMENT_TAG);
098        tagOrder.add(GenbankFormat.FEATURE_TAG);
099    }
100
101    public int compare(Object o1, Object o2)
102    {
103        int index1 = tagOrder.indexOf(o1);
104        int index2 = tagOrder.indexOf(o2);
105
106        return (index1 - index2);
107    }
108}