/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package nl.wur.plantbreeding.gff2RDF;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import nl.wur.plantbreeding.gff2RDF.object.Gene;

/**
 *
 * @author pierrey
 */
public class PPI {

    /**
     * This URI is the based used to create the RDF of non-standard URI.
     * For example, gene will have a type: URI/GENE#
     * they will have a position: URI/POSITION# which will have a starting
     * position: URI/POSITION#Start.
     *
     * You may change it to fit your needs.
     */
    private String uri = "http://pbr.wur.nl/";
    /** Logger used for outputing log information. */
    private static final Logger LOG = Logger.getLogger(
            ObjectToModel.class.getName());

    /**
     * Start-up function.
     * @param args command line argument given
     */
    public static void main(final String[] args) {
        String folder = "/home/pierrey/Documents/Projects/Marker2Sequence/";
        String filename = "intact.txt";

        Model model = ModelFactory.createDefaultModel();
        try {
            model = PPI.getModelFromGff(folder + filename, model);
        } catch (IOException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }

        System.out.println("Model final: " + model.size());
        try {
            if (!model.isEmpty()) {
                ModelIO mio = new ModelIO();
                String outputfilename = "ppimodel.rdf";
                mio.printModelToFile(model, outputfilename);
            }
        } catch (IOException ex) {
            System.err.println();
            LOG.log(Level.SEVERE, "Error while writting: {0}", ex.getMessage());
                ex.printStackTrace(System.err);
        }
    }

    /**
     * Parse the tab delimited file and generate the model from it.
     * @param inputfilename the full path to the file.
     * @param model the Jena Model in which to add the info.
     * @return a Jena Model object containing the protein-protein interaction
     * information.
     * @throws IOException when something goes wrong while trying to read the
     * file.
     */
    public static Model getModelFromGff(final String inputfilename,
            Model model) throws IOException {

        System.out.println("Parsing: " + inputfilename
                + " and adding information to a model of size " + model.size());

        ObjectToModel obj2m = new ObjectToModel();

        int cnt = 0;
        int protcnt = 0;
        String strline = "";
        final FileInputStream fstream = new FileInputStream(inputfilename);
        // Get the object of DataInputStream
        final DataInputStream in = new DataInputStream(fstream);
        final BufferedReader br =
                new BufferedReader(new InputStreamReader(in));
        //Read File Line By Line
        while ((strline = br.readLine()) != null) {
            strline = strline.trim();
            String[] content = strline.split("\t");
            if (cnt > 1) {
                String prot1 = content[0].split("\\|")[0].split(":")[1];
                String prot2 = content[1].split("\\|")[0].split(":")[1];
                // Add ppi to model
                model = obj2m.addProteinProteinInteractionToModel(prot1, prot2,
                        model);
                protcnt = protcnt + 1;
            }
            cnt = cnt + 1;
        }
        in.close();

        LOG.log(Level.FINE, cnt + " lines read");
        LOG.log(Level.FINE, protcnt + " ppi found");
        LOG.log(Level.FINE, "Model has size: " + model.size());

        return model;
    }

}

@@ -93,17 +93,16 @@
 or.%0A */%0A
-%0A
 package 
@@ -368,32 +368,146 @@
 utStreamReader;%0A
+import java.net.MalformedURLException;%0Aimport java.util.HashMap;%0Aimport java.util.Iterator;%0Aimport java.util.Set;%0A
 import java.util
@@ -1302,24 +1302,25 @@
 args) %7B%0A
+%0A
         
 String f
@@ -1315,255 +1315,1018 @@
     
-String folder = %22/home/pierrey/Documents/Projects/Marker2Sequence/%22;%0A        String filename = %22intact.txt%22;%0A%0A        Model model = ModelFactory.createDefaultModel();%0A        try %7B%0A            model = PPI.getModelFromGff(folder + filename, model);
+HashMap%3CString, String%3E urls = new HashMap%3CString, String%3E();%0A        urls.put(%22ftp://ftp.ebi.ac.uk/pub/databases/intact/current/psimitab/intact.txt%22,%0A                %22intact.txt%22);%0A        urls.put(%22ftp://ftp.ebi.ac.uk/pub/databases/intact/current/psimitab/intact-clustered.txt%22,%0A                %22intact-clustered.txt%22);%0A        Set%3CString%3E urlset = urls.keySet();%0A        int cnt = 0;%0A        for (Iterator%3CString%3E it = urlset.iterator(); it.hasNext();) %7B%0A            String key = it.next();%0A            cnt = cnt + 1;%0A            try %7B%0A                App.downaloadFile(key, urls.get(key), false);%0A            %7D catch (IOException ex) %7B%0A                LOG.log(Level.SEVERE, null, ex);%0A            %7D%0A        %7D%0A        System.out.println();%0A%0A        Model model = ModelFactory.createDefaultModel();%0A        try %7B%0A            for (Iterator%3CString%3E it = urlset.iterator(); it.hasNext();) %7B%0A                String key = it.next();%0A                model = PPI.getModelFromGff(urls.get(key), model);%0A            %7D
 %0A   
@@ -2861,20 +2861,16 @@
         
-    
 ex.print
@@ -4764,11 +4764,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Add the code to do the downloading of the lastest files