Skip to content
Snippets Groups Projects
Commit 6d88f368 authored by tcarver's avatar tcarver
Browse files

Merge pull request #175 from satta/filter_qualifiers

allow to exclude attributes from GFF3 output
parents f567d6d5 0179a734
No related branches found
No related tags found
No related merge requests found
...@@ -27,8 +27,10 @@ package uk.ac.sanger.artemis.io; ...@@ -27,8 +27,10 @@ package uk.ac.sanger.artemis.io;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.HashSet;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.Vector; import java.util.Vector;
import java.io.IOException; import java.io.IOException;
...@@ -113,6 +115,28 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -113,6 +115,28 @@ public class GFFStreamFeature extends SimpleDocumentFeature
{ "\n", "%5C" } // new-line { "\n", "%5C" } // new-line
}; };
private static Set<String> attrs_to_filter = new HashSet<String>();
/**
* Registers an attribute not to be included in the GFF3 output for
* GFFStreamFeatures
* @param attr The GFF3 attribute to remove
**/
public static void removeAttribute(String attr)
{
attrs_to_filter.add(attr);
}
/**
* Registers an attribute to be included in the GFF3 output for
* GFFStreamFeatures
* @param attr The GFF3 attribute to include
**/
public static void includeAttribute(String attr)
{
attrs_to_filter.remove(attr);
}
/** /**
* Create a new GFFStreamFeature object. The feature should be added * Create a new GFFStreamFeature object. The feature should be added
* to an Entry (with Entry.add()). * to an Entry (with Entry.add()).
...@@ -893,6 +917,9 @@ public class GFFStreamFeature extends SimpleDocumentFeature ...@@ -893,6 +917,9 @@ public class GFFStreamFeature extends SimpleDocumentFeature
if(lname) if(lname)
continue; continue;
if(attrs_to_filter.contains(this_qualifier.getName()))
continue;
if( (this_qualifier.getName().equals("private") && System.getProperty("noprivate") != null) || if( (this_qualifier.getName().equals("private") && System.getProperty("noprivate") != null) ||
(this_qualifier.getName().equals("history") && System.getProperty("nohistory") != null) ) (this_qualifier.getName().equals("history") && System.getProperty("nohistory") != null) )
continue; continue;
......
...@@ -294,6 +294,7 @@ public class ReadAndWriteEntry ...@@ -294,6 +294,7 @@ public class ReadAndWriteEntry
System.out.println("-h\tshow help"); System.out.println("-h\tshow help");
System.out.println("-f\t[y|n] flatten the gene model, default is y"); System.out.println("-f\t[y|n] flatten the gene model, default is y");
System.out.println("-flt\tspace separated list of qualifiers to ignore (GFF only)");
System.out.println("-i\t[y|n] ignore obsolete features, default is y"); System.out.println("-i\t[y|n] ignore obsolete features, default is y");
System.out.println("-s\tspace separated list of sequences to read and write out"); System.out.println("-s\tspace separated list of sequences to read and write out");
System.out.println("-o\t[EMBL|GFF] output format, default is EMBL"); System.out.println("-o\t[EMBL|GFF] output format, default is EMBL");
...@@ -407,6 +408,18 @@ public class ReadAndWriteEntry ...@@ -407,6 +408,18 @@ public class ReadAndWriteEntry
if(args[j].startsWith("-")) if(args[j].startsWith("-"))
break; break;
files.add(args[j]); files.add(args[j]);
i++;
}
}
else if(args[i].toLowerCase().equals("-flt"))
{
for(int j = i + 1; j < args.length; j++)
{
if(args[j].startsWith("-")) {
break;
}
GFFStreamFeature.removeAttribute(args[j]);
i++;
} }
} }
else if(args[i].startsWith("-")) else if(args[i].startsWith("-"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment