-
-
Save carrere/90b63b7c66913ad2cdd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.intermine.bio.dataconversion; | |
import org.intermine.bio.io.gff3.GFF3Record; | |
import org.intermine.metadata.Model; | |
import org.intermine.xml.full.Item; | |
import java.util.List; | |
import java.util.ArrayList; | |
import org.intermine.objectstore.ObjectStoreException; | |
public class GffBfcGFF3RecordHandler extends GFF3RecordHandler | |
{ | |
private String geneRefId = null; | |
/** | |
* Create a new GffBfcGFF3RecordHandler for the given data model. | |
* @param model the model for which items will be created | |
*/ | |
public GffBfcGFF3RecordHandler (Model model) { | |
super(model); | |
//Creation des liens entre objets | |
refsAndCollections.put("Exon", "transcripts"); | |
refsAndCollections.put("MRNA", "gene"); | |
refsAndCollections.put("Protein", "gene"); | |
} | |
@Override | |
public void process(GFF3Record record) { | |
Item feature = getFeature(); | |
//Recuperation du contenu de Note dans un attribut "product" | |
if (record.getAttributes().containsKey("Note")) | |
{ | |
List<String> noteList = record.getAttributes().get("Note"); | |
if (! noteList.isEmpty()) | |
{ | |
String product = noteList.get(0); | |
feature.setAttribute("product", product);} | |
} | |
String clsName = feature.getClassName(); | |
if ("Gene".equals(clsName)) | |
{ | |
//Stockage du dernier ID de gene rencontre | |
geneRefId = record.getAttributes().get("ID").get(0); | |
} | |
else if ("CDS".equals(clsName)) | |
{ | |
//Recuperation de l'item du dernier gene rencontre | |
// --> il faut son primaryId et son organisme | |
Item gene = super.converter.createItem("Gene"); | |
gene.setAttribute("primaryIdentifier", geneRefId); | |
gene.setReference("organism", super.getOrganism()); | |
//Creation d'un item protein associe | |
Item protein = super.converter.createItem("Protein"); | |
protein.setAttribute("primaryIdentifier", record.getAttributes().get("Name").get(0)); | |
gene.addToCollection("proteins", protein); | |
//Stockage de cet item (la feature en cours est automatiquement "storée" | |
// mais ce n'est pas le cas pour l'item créé à la volée | |
try { super.converter.store(protein); } catch (ObjectStoreException e) { e.printStackTrace();} | |
//Lien CDS (la feature en cours <-> protein | |
feature.setReference("protein", protein); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment