Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package task_3.task_3;
- /*
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.util.Iterator;
- //import javax.swing.text.html.HTMLDocument.Iterator;
- import org.biojava.bio.BioException;
- import org.biojava.bio.seq.Feature;
- import org.biojava.bio.seq.FeatureFilter;
- import org.biojava.bio.seq.FeatureHolder;
- import org.biojavax.Note;
- import org.biojavax.RichAnnotation;
- import org.biojavax.RichObjectFactory;
- import org.biojavax.bio.seq.RichFeature;
- import org.biojavax.bio.seq.RichSequence;
- import org.biojavax.ontology.ComparableTerm;
- */
- //Java libraries
- import java.io.*;
- import java.util.*;
- //BioJava libraries
- import org.biojava.bio.*;
- import org.biojava.bio.seq.*;
- import org.biojava.bio.seq.io.*;
- //BioJava extension libraries
- import org.biojavax.*;
- import org.biojavax.ontology.*;
- import org.biojavax.bio.*;
- import org.biojavax.bio.seq.*;
- public class ExtractInformation {
- //Create the RichSequence object
- RichSequence richSeq;
- //ExtractInformation constructor
- public ExtractInformation(String fileName){
- //fileName = "ACTG1.gb" ;
- //Load the sequence file
- try {
- richSeq = RichSequence.IOTools.readGenbankDNA(new BufferedReader(new FileReader(fileName)),null).nextRichSequence();
- }
- catch(FileNotFoundException fnfe){
- System.out.println("FileNotFoundException: " + fnfe);
- }
- catch(BioException bioe1){
- System.err.println("Not a Genbank sequence trying EMBL");
- try {
- richSeq = RichSequence.IOTools.readEMBLDNA(new BufferedReader(new FileReader(fileName)),null).nextRichSequence();
- }
- catch(BioException bioe2){
- System.err.println("Not an EMBL sequence either");
- System.exit(1);
- }
- catch(FileNotFoundException fnfe){
- System.out.println("FileNotFoundException: " + fnfe);
- }
- }
- //Filter the sequence on CDS features
- FeatureFilter ff = new FeatureFilter.ByType("CDS");
- FeatureHolder fh = richSeq.filter(ff);
- //Iterate through the CDS features
- for (Iterator i = fh.features(); i.hasNext();){//мб косяк в итераторе будет
- RichFeature rf = (RichFeature)i.next();
- //Get the strand orientation of the feature
- char featureStrand = rf.getStrand().getToken();
- //Get the location of the feature
- String featureLocation = rf.getLocation().toString();
- System.out.println(featureLocation);
- }
- }
- //Main method
- public static void main(String args []) {
- if (args.length != 1){
- System.out.println("Usage: java ExtractInformation ``");
- System.exit(1);
- } else {
- new ExtractInformation(args[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement