Skip to content
Snippets Groups Projects
Commit 9845b4bd authored by tjc's avatar tjc
Browse files

gff3

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@2420 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent bbbfdac6
No related branches found
No related tags found
No related merge requests found
......@@ -20,18 +20,169 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFEntryInformation.java,v 1.1 2004-06-09 09:49:31 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFEntryInformation.java,v 1.2 2005-04-26 14:31:44 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
import java.io.InputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
import uk.ac.sanger.artemis.util.StringVector;
import uk.ac.sanger.artemis.Options;
/**
* An EntryInformation object for GFFDocumentEntry objects.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: GFFEntryInformation.java,v 1.1 2004-06-09 09:49:31 tjc Exp $
* @version $Id: GFFEntryInformation.java,v 1.2 2005-04-26 14:31:44 tjc Exp $
**/
public class GFFEntryInformation extends SimpleEntryInformation
{
public GFFEntryInformation()
{
super();
try
{
makeEntryInformation();
}
catch(QualifierInfoException e)
{
System.err.println("could not initialise the embl package: " +
e.getMessage());
System.exit(1);
}
catch(IOException e)
{
System.err.println("could not initialise the embl package: " +
e.getMessage());
System.exit(1);
}
}
/**
* Return an EntryInformation object that is suitable for EMBL and GENBANK
* entries.
**/
private void makeEntryInformation()
throws IOException, QualifierInfoException
{
final InputStream feature_keys_stream =
Options.class.getResourceAsStream("/etc/feature_keys_gff");
final InputStream qualifier_types_stream =
Options.class.getResourceAsStream("/etc/qualifier_types_gff");
QualifierInfoVector qualifier_info_vector =
readQualifierInfo(qualifier_types_stream, feature_keys_stream);
for(int i = 0 ; i < qualifier_info_vector.size() ; ++i)
{
final QualifierInfo qualifier_info =
qualifier_info_vector.elementAt(i);
addQualifierInfo(qualifier_info);
}
// entry_information.setEMBLFormat(true);
}
/**
* Read the possible feature key and qualifier names and types from the two
* given streams (see etc/feature_keys and etc/qualifier_types for details
* on the formats).
**/
private static QualifierInfoVector
readQualifierInfo(final InputStream qualifier_types_stream,
final InputStream feature_keys_stream)
throws IOException
{
final QualifierInfoVector return_vector = new QualifierInfoVector();
Properties feature_properties = new Properties();
final Properties qualifier_properties = new Properties();
feature_properties.load(feature_keys_stream);
qualifier_properties.load(qualifier_types_stream);
public class GFFEntryInformation extends SimpleEntryInformation {
// parse the feature_properties
{
final Properties new_feature_properties = new Properties();
final Enumeration feature_enum = feature_properties.propertyNames();
while(feature_enum.hasMoreElements())
{
String current_feature_name = (String) feature_enum.nextElement();
final StringVector property_values =
Options.getPropertyValues(feature_properties, current_feature_name);
new_feature_properties.put(current_feature_name, property_values);
}
feature_properties = new_feature_properties;
}
final Enumeration qualifier_enum = qualifier_properties.propertyNames();
while(qualifier_enum.hasMoreElements())
{
String current_qualifier_name = (String) qualifier_enum.nextElement();
final StringVector current_qualifier_values =
Options.getPropertyValues(qualifier_properties,
current_qualifier_name);
final boolean once_only =
current_qualifier_values.elementAt(0).equals("yes");
final String type_string = current_qualifier_values.elementAt(1);
// find the keys for which this qualifier name is valid or required
final KeyVector valid_keys = new KeyVector();
final KeyVector required_keys = new KeyVector();
final Enumeration features_enum = feature_properties.propertyNames();
while(features_enum.hasMoreElements())
{
final String current_key_string = (String)features_enum.nextElement();
final Key current_key = new Key(current_key_string);
final StringVector current_feature_qualifiers =
(StringVector) feature_properties.get(current_key_string);
if(current_feature_qualifiers.contains(current_qualifier_name))
valid_keys.add(current_key);
else
if(current_feature_qualifiers.contains("@" +
current_qualifier_name))
{
valid_keys.add(current_key);
required_keys.add(current_key);
}
}
final int type = QualifierInfo.getQualifierTypeID(type_string);
final QualifierInfo qualifier_info =
new QualifierInfo(current_qualifier_name, type, valid_keys,
required_keys, once_only);
return_vector.add(qualifier_info);
}
return return_vector;
}
}
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFStreamFeature.java,v 1.7 2005-04-22 15:26:47 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFStreamFeature.java,v 1.8 2005-04-26 14:31:44 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -35,7 +35,7 @@ import java.util.StringTokenizer;
* A StreamFeature that thinks it is a GFF feature.
*
* @author Kim Rutherford
* @version $Id: GFFStreamFeature.java,v 1.7 2005-04-22 15:26:47 tjc Exp $
* @version $Id: GFFStreamFeature.java,v 1.8 2005-04-26 14:31:44 tjc Exp $
**/
public class GFFStreamFeature extends SimpleDocumentFeature
......@@ -525,6 +525,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
count++;
}
boolean lname;
for(int i = 0 ; i < qualifiers.size() ; ++i)
{
this_qualifier = (Qualifier)qualifiers.elementAt(i);
......@@ -533,8 +534,12 @@ public class GFFStreamFeature extends SimpleDocumentFeature
if(this_qualifier_str == null)
continue;
lname = false;
for(int j=0; j<names.length; j++)
if(this_qualifier_str.equals(names[j]))
if(this_qualifier_str.startsWith(names[j]))
lname = true;
if(lname)
continue;
if(count != 0)
......@@ -579,7 +584,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
catch (NumberFormatException __)
{
// not a double or integer so quote it
buffer.append('"' + encode(this_value) + '"');
buffer.append(encode(this_value));
}
}
}
......@@ -609,7 +614,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
final String this_token = tokeniser.nextToken().trim();
int index_of_first_space = this_token.indexOf(" ");
final String att_name;
String att_name;
final StringVector att_values = new StringVector();
if( this_token.indexOf("=") > -1 &&
......
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/sequence/Bases.java,v 1.11 2005-01-11 13:24:38 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/sequence/Bases.java,v 1.12 2005-04-26 14:31:44 tjc Exp $
*/
package uk.ac.sanger.artemis.sequence;
......@@ -45,7 +45,7 @@ import java.util.Iterator;
* non-base letter returns '@'.
*
* @author Kim Rutherford
* @version $Id: Bases.java,v 1.11 2005-01-11 13:24:38 tjc Exp $ */
* @version $Id: Bases.java,v 1.12 2005-04-26 14:31:44 tjc Exp $ */
public class Bases
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment