Skip to content

Instantly share code, notes, and snippets.

@kozo2
Created April 14, 2014 22:38
Show Gist options
  • Save kozo2/10687761 to your computer and use it in GitHub Desktop.
Save kozo2/10687761 to your computer and use it in GitHub Desktop.
biopax paxtools
package bar;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Set;
import org.biopax.paxtools.io.BioPAXIOHandler;
import org.biopax.paxtools.io.SimpleIOHandler;
import org.biopax.paxtools.model.Model;
import org.biopax.paxtools.model.level3.Protein;
public class aaa {
public static void main(String[] args) throws FileNotFoundException {
FileInputStream fin = new FileInputStream(
"/Users/knishida/biopax-level3.owl");
BioPAXIOHandler handler = new SimpleIOHandler();
Model model = handler.convertFromOWL(fin);
Set<Protein> proteinSet = model.getObjects(Protein.class);
File file = new File("aaa.tsv");
try {
FileWriter filewriter = new FileWriter(file);
filewriter.write("availability\tcomponent\tcontrollerof\tdatasource\tentityref\txref\tlongname\tcomment\tname\n");
for (Protein currentProtein : proteinSet) {
filewriter.write(currentProtein.getAvailability() + "\t"
// + currentProtein.getCellularLocation().toString() + "\t"
+ currentProtein.getComponentOf().toString() + "\t"
+ currentProtein.getControllerOf().toString() + "\t"
+ currentProtein.getDataSource().toString() + "\t"
+ currentProtein.getEntityReference().getXref() + "\t"
+ currentProtein.getXref().toString() + "\t"
+ currentProtein.getStandardName() + "\t"
+ currentProtein.getComment() + "\t"
+ currentProtein.getDisplayName() + "\n");
}
filewriter.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("OK");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment