package org.flymine.dataconversion;

/*
 * Copyright (C) 2002-2005 FlyMine
 *
 * This code may be freely distributed and modified under the
 * terms of the GNU Lesser General Public Licence.  This should
 * be distributed with the code.  See the LICENSE file for more
 * information or http://www.gnu.org/copyleft/lesser.html.
 *
 */

import java.util.HashMap;
import java.util.Map;

import org.intermine.metadata.Model;

import org.flymine.io.gff3.GFF3Record;

/**
 * A converter/retriever for the Drosophila tiling path GFF3 files.
 *
 * @author Kim Rutherford
 */

public class TilingPathGFF3RecordHandler extends GFF3RecordHandler
{
    private Map references;

    /**
     * Create a new TilingPathGFF3RecordHandler for the given target model.
     * @param tgtModel the model for which items will be created
     */
    public TilingPathGFF3RecordHandler (Model tgtModel) {
        super(tgtModel);

        // create a map of classname to reference name for parent references
        // this will add the parents of any SimpleRelations from getParents() to the
        // given collection
        references = new HashMap();
        references.put("PCRProduct", "tilingPathSpan");
        references.put("ForwardPrimer", "pcrProduct");
        references.put("ReversePrimer", "pcrProduct");
    }

    /**
     * @see GFF3RecordHandler#process()
     */
    public void process(GFF3Record record) {
        setReferences(references);
    }
}

@@ -375,16 +375,39 @@
 til.Map;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -436,16 +436,87 @@
 a.Model;
+%0Aimport org.intermine.xml.full.Item;%0Aimport org.intermine.util.XmlUtil;
 %0A%0Aimport
@@ -1490,24 +1490,540 @@
 d record) %7B%0A
+%0A        Item feature = getFeature();%0A        String clsName = XmlUtil.getFragmentFromURI(feature.getClassName());%0A%0A        if (clsName.equals(%22PCRProduct%22)) %7B%0A%0A            System.err.println (%22record: %22 + record);%0A%0A            List promoters = (List) record.getAttributes().get(%22promotor%22);%0A            %0A            if (promoters.get(0).equals(%221%22)) %7B%0A                feature.setAttribute(%22promoter%22, %22true%22);%0A            %7D else %7B%0A                feature.setAttribute(%22promoter%22, %22false%22);%0A            %7D%0A        %7D%0A%0A
         setR

Set the promoter field in PCRProduct.