Permalink
Browse files

some changes/updates

  • Loading branch information...
1 parent ae569b7 commit b0afc868d46ca06275da11e1868756304c5eda68 @pablopareja pablopareja committed May 10, 2012
View
106 src/org/grassius/grg/GRGImporter.java
@@ -17,11 +17,16 @@
package org.grassius.grg;
import com.era7.lib.bioinfo.bioinfoutil.Executable;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
import java.util.ArrayList;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
+import org.grassius.grg.model.GRGManager;
+import org.grassius.grg.model.nodes.ChromosomeNode;
import org.neo4j.graphdb.index.BatchInserterIndex;
import org.neo4j.graphdb.index.BatchInserterIndexProvider;
import org.neo4j.helpers.collection.MapUtil;
@@ -57,16 +62,16 @@ public void execute(ArrayList<String> array) {
public static void main(String[] args) {
- if (args.length != 3) {
- System.out.println("This program expects four parameters: \n"
+ if (args.length != 2) {
+ System.out.println("This program expects the following parameters: \n"
+ "1. Bio4j DB folder" + "\n"
- + "2. BatchInserter properties file");
+ + "2. GFF file ");
} else {
- BatchInserter inserter = null;
- BatchInserterIndexProvider indexProvider = null;
+ GRGManager gRGManager = null;
+ String tempLine = "";
try {
@@ -78,18 +83,80 @@ public static void main(String[] args) {
logger.setLevel(Level.ALL);
String bio4jdbFolder = args[0];
- String batchInserterPropsFile = args[1];
-
- // create the batch inserter
- inserter = new BatchInserterImpl(bio4jdbFolder, BatchInserterImpl.loadProperties(batchInserterPropsFile));
-
- // create the batch index service
- indexProvider = new LuceneBatchInserterIndexProvider(inserter);
+ String gffFileSt = args[1];
+
+ System.out.println("Creating manager....");
- //------------------indexes creation----------------------------------
- //BatchInserterIndex proteinAccessionIndex = indexProvider.nodeIndex(ProteinNode.PROTEIN_ACCESSION_INDEX,
- // MapUtil.stringMap(PROVIDER_ST, LUCENE_ST, TYPE_ST, EXACT_ST));
- //--------------------------------------------------------------------
+ gRGManager = new GRGManager(bio4jdbFolder);
+
+
+ File gffFile = new File(gffFileSt);
+
+ BufferedReader reader = new BufferedReader(new FileReader(gffFile));
+ String line = null;
+
+ System.out.println("Reading gff file....");
+
+ //----skip header---
+ reader.readLine();
+
+ while((line = reader.readLine()) != null){
+
+ tempLine = line;
+ String[] columns = line.split("\t");
+
+ String chromosomeSt = columns[0];
+ String elementTypeSt = columns[2];
+ int startPosition = Integer.parseInt(columns[3]);
+ int endPosition = Integer.parseInt(columns[4]);
+ String strandSt = columns[6];
+ String descriptionSt = columns[8];
+
+ String[] descriptionColumns = descriptionSt.split(";");
+
+
+ //----------------------GENE--------------------------
+ if(elementTypeSt.equals("gene")){
+
+ String geneID = descriptionColumns[0].split("ID=")[1];
+ System.out.println("geneID = " + geneID);
+
+ }
+ //----------------------CDS--------------------------
+ else if(elementTypeSt.equals("CDS")){
+
+ String elementId = descriptionColumns[0].split("ID=PAC")[1].substring(1);
+ //System.out.println("CDS: elementId = " + elementId);
+
+ }
+ //----------------------mRNA--------------------------
+ else if(elementTypeSt.equals("mRNA")){
+
+ String elementId = descriptionColumns[0].split("ID=PAC")[1].substring(1);
+ //System.out.println("mRNA: elementId = " + elementId);
+
+ }
+ //----------------------EXON--------------------------
+ else if (elementTypeSt.equals("exon")){
+ String elementId = descriptionColumns[0].split("ID=PAC")[1].substring(1);
+ //System.out.println("exon: elementId = " + elementId);
+ }
+ //----------------------FIVE PRIME UTR--------------------------
+ else if (elementTypeSt.equals("five_prime_UTR")){
+ String elementId = descriptionColumns[0].split("ID=PAC")[1].substring(1);
+ //System.out.println("five_prime_UTR: elementId = " + elementId);
+ }
+ //----------------------THREE PRIME UTR--------------------------
+ else if(elementTypeSt.equals("three_prime_UTR")){
+ String elementId = descriptionColumns[0].split("ID=PAC")[1].substring(1);
+ //System.out.println("three_prime_UTR: elementId = " + elementId);
+ }
+
+
+ }
+
+
+ reader.close();
@@ -99,13 +166,14 @@ public static void main(String[] args) {
for (StackTraceElement stackTraceElement : trace) {
logger.log(Level.SEVERE, stackTraceElement.toString());
}
+
+ System.out.println("tempLine: " + tempLine);
} finally {
try {
//closing logger file handler
fh.close();
- //closing no4j managers
- indexProvider.shutdown();
- inserter.shutdown();
+ //closing managers
+ gRGManager.shutDown();
} catch (Exception e) {
logger.log(Level.SEVERE, e.getMessage());
StackTraceElement[] trace = e.getStackTrace();
View
7 src/org/grassius/grg/model/nodes/ChromosomeNode.java
@@ -24,7 +24,7 @@
import org.grassius.grg.model.relationships.CisElementChromosomeRel;
import org.grassius.grg.model.relationships.GRGGeneChromosomeRel;
import org.grassius.grg.model.relationships.GRGMRNAChromosomeRel;
-import org.grassius.grg.model.relationships.GenomeElementChromosomeRel;
+import org.grassius.grg.model.relationships.ChromosomeNCBITaxonRel;
import org.grassius.grg.model.relationships.PromoterChromosomeRel;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.Node;
@@ -40,15 +40,18 @@
public static final String CHROMOSOME_ID_INDEX = "chromoshome_id_index";
public static final String ID_PROPERTY = "id";
+ public static final String LENGTH_PROPERTY = "length";
public ChromosomeNode(Node n){
super(n);
}
public String getId(){ return String.valueOf(node.getProperty(ID_PROPERTY));}
+ public int getLength(){ return Integer.parseInt(String.valueOf(node.getProperty(LENGTH_PROPERTY)));}
public void setId(String value){ node.setProperty(ID_PROPERTY, value);}
+ public void setLength(int value){ node.setProperty(LENGTH_PROPERTY, value);}
@Override
@@ -100,7 +103,7 @@ public boolean equals(Object obj) {
}
public GenomeElementNode getGenomeElement(){
GenomeElementNode genomeElementNode = null;
- Iterator<Relationship> iterator = this.getNode().getRelationships(new GenomeElementChromosomeRel(null), Direction.INCOMING).iterator();
+ Iterator<Relationship> iterator = this.getNode().getRelationships(new ChromosomeNCBITaxonRel(null), Direction.INCOMING).iterator();
if(iterator.hasNext()){
genomeElementNode = new GenomeElementNode(iterator.next().getStartNode());
}
View
39 src/org/grassius/grg/model/relationships/ChromosomeNCBITaxonRel.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2012 "GRG"
+ *
+ * This file is part of GRG
+ *
+ * Bio4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ */
+package org.grassius.grg.model.relationships;
+
+import com.era7.bioinfo.bioinfoneo4j.BasicRelationship;
+import org.neo4j.graphdb.Relationship;
+
+/**
+ *
+ * @author Pablo Pareja Tobes <ppareja@era7.com>
+ */
+public class ChromosomeNCBITaxonRel extends BasicRelationship{
+
+ public static final String NAME = "CHROMOSOME_NCBI_TAXON";
+
+ public ChromosomeNCBITaxonRel(Relationship rel){
+ super(rel);
+ }
+
+ @Override
+ public String name() {
+ return NAME;
+ }
+
+}

0 comments on commit b0afc86

Please sign in to comment.