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

changes for writing out EMBL from database entry

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@6421 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 3d947bcd
No related branches found
No related tags found
No related merge requests found
......@@ -69,8 +69,8 @@ public class DatabaseDocumentEntry extends GFFDocumentEntry
* it, otherwise create and return a new feature of the appropriate type.
* @param copy if true then always new a new copy of the Feature.
**/
protected SimpleDocumentFeature makeNativeFeature(final Feature feature,
final boolean copy)
protected Object makeNativeFeature(final Feature feature,
final boolean copy)
{
if (!copy)
{
......
......@@ -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/GFFDocumentEntry.java,v 1.48 2007-09-11 11:00:37 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFDocumentEntry.java,v 1.49 2007-09-25 09:59:57 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -42,7 +42,7 @@ import java.sql.Timestamp;
* A DocumentEntry that can read an GFF entry from a Document.
*
* @author Kim Rutherford
* @version $Id: GFFDocumentEntry.java,v 1.48 2007-09-11 11:00:37 tjc Exp $
* @version $Id: GFFDocumentEntry.java,v 1.49 2007-09-25 09:59:57 tjc Exp $
**/
public class GFFDocumentEntry extends SimpleDocumentEntry
......@@ -126,8 +126,8 @@ public class GFFDocumentEntry extends SimpleDocumentEntry
* it, otherwise create and return a new feature of the appropriate type.
* @param copy if true then always new a new copy of the Feature.
**/
protected SimpleDocumentFeature makeNativeFeature(final Feature feature,
final boolean copy)
protected Object makeNativeFeature(final Feature feature,
final boolean copy)
{
if(!copy && feature instanceof GFFStreamFeature)
return (GFFStreamFeature)feature;
......
......@@ -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/MSPcrunchDocumentEntry.java,v 1.1 2004-06-09 09:49:57 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/MSPcrunchDocumentEntry.java,v 1.2 2007-09-25 09:59:57 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -34,7 +34,7 @@ import java.io.*;
* MSPcrunch -d or -x output.
*
* @author Kim Rutherford
* @version $Id: MSPcrunchDocumentEntry.java,v 1.1 2004-06-09 09:49:57 tjc Exp $
* @version $Id: MSPcrunchDocumentEntry.java,v 1.2 2007-09-25 09:59:57 tjc Exp $
**/
public class MSPcrunchDocumentEntry extends SimpleDocumentEntry
......@@ -95,7 +95,7 @@ public class MSPcrunchDocumentEntry extends SimpleDocumentEntry
* it, otherwise create and return a new feature of the appropriate type.
* @param copy if true then always new a new copy of the Feature.
**/
protected SimpleDocumentFeature makeNativeFeature (final Feature feature,
protected Object makeNativeFeature (final Feature feature,
final boolean copy) {
if (!copy && feature instanceof MSPcrunchStreamFeature) {
return (MSPcrunchStreamFeature) feature;
......
......@@ -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/PublicDBDocumentEntry.java,v 1.3 2007-09-21 15:26:22 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/PublicDBDocumentEntry.java,v 1.4 2007-09-25 09:59:57 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -35,7 +35,7 @@ import java.io.IOException;
* entry.
*
* @author Kim Rutherford
* @version $Id: PublicDBDocumentEntry.java,v 1.3 2007-09-21 15:26:22 tjc Exp $
* @version $Id: PublicDBDocumentEntry.java,v 1.4 2007-09-25 09:59:57 tjc Exp $
**/
public class PublicDBDocumentEntry extends SimpleDocumentEntry
......@@ -103,7 +103,7 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry
* it, otherwise create and return a new feature of the appropriate type.
* @param copy if true then always new a new copy of the Feature.
**/
protected SimpleDocumentFeature makeNativeFeature(final Feature feature,
protected Object makeNativeFeature(final Feature feature,
final boolean copy)
{
if (!copy && (feature instanceof EmblStreamFeature &&
......@@ -115,16 +115,12 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry
}
else
{
final PublicDBStreamFeature feature_copy;
if(feature instanceof GFFStreamFeature)
feature_copy = mapGffToNativeFeature(feature);
return mapGffToNativeFeature(feature);
else if (this instanceof EmblDocumentEntry)
feature_copy = new EmblStreamFeature (feature);
return new EmblStreamFeature(feature);
else
feature_copy = new GenbankStreamFeature (feature);
return feature_copy;
return new GenbankStreamFeature(feature);
}
}
......@@ -133,18 +129,31 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry
* @param feature
* @return
*/
private PublicDBStreamFeature mapGffToNativeFeature(final Feature feature)
private Object mapGffToNativeFeature(final Feature feature)
{
final String[] QUALIFIERS_TO_REMOVE =
{
"timelastmodified", "ID", "feature_id", "Parent", "Derives_from", "feature_relationship_rank"
"timelastmodified",
"ID",
"comment", // convert to note
"feature_id",
"Parent",
"Derives_from",
"feature_relationship_rank"
};
Key key = feature.getKey();
QualifierVector qualifiers = feature.getQualifiers().copy();
try
{
int index;
int index = qualifiers.indexOfQualifierWithName("comment");
if(index > -1)
{
StringVector comments = ((Qualifier)qualifiers.get(index)).getValues();
Qualifier noteQualifier = new Qualifier("note", comments);
qualifiers.setQualifier(noteQualifier);
}
for(int i=0; i<QUALIFIERS_TO_REMOVE.length; i++)
{
......@@ -152,9 +161,10 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry
if(index > -1)
qualifiers.removeElementAt(index);
}
if(key.getKeyString().equals(DatabaseDocument.EXONMODEL))
key = new Key("exon");
key = new Key("CDS");
else if(key.getKeyString().startsWith("pseudo"))
{
if(key.getKeyString().equals("pseudogenic_transcript"))
......@@ -178,6 +188,35 @@ public class PublicDBDocumentEntry extends SimpleDocumentEntry
}
}
//
// create separate exon features for each range in a CDS
// (returns an array of SimpleDocumentFeature)
if(key.getKeyString().equals("CDS"))
{
RangeVector ranges = feature.getLocation().getRanges();
SimpleDocumentFeature[] features =
new SimpleDocumentFeature[ranges.size() + 1];
features[0] = new EmblStreamFeature(key, feature.getLocation(),
qualifiers);
for(int i = 0; i < ranges.size(); i++)
{
try
{
features[i + 1] = new EmblStreamFeature(new Key("exon"),
new Location((Range) ranges.get(i)), qualifiers);
}
catch(OutOfRangeException e)
{
e.printStackTrace();
}
}
return features;
}
if(this instanceof EmblDocumentEntry)
return new EmblStreamFeature (
key,
......
......@@ -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/SimpleDocumentEntry.java,v 1.20 2007-06-15 12:57:32 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/SimpleDocumentEntry.java,v 1.21 2007-09-25 09:59:57 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -38,7 +38,7 @@ import javax.swing.JOptionPane;
* This class contains the methods common to all DocumentEntry objects.
*
* @author Kim Rutherford <kmr@sanger.ac.uk>
* @version $Id: SimpleDocumentEntry.java,v 1.20 2007-06-15 12:57:32 tjc Exp $
* @version $Id: SimpleDocumentEntry.java,v 1.21 2007-09-25 09:59:57 tjc Exp $
**/
abstract public class SimpleDocumentEntry
......@@ -340,13 +340,20 @@ abstract public class SimpleDocumentEntry
{
if(force)
{
if(forcedAdd(makeNativeFeature(new_feature, true)) == null)
if(forcedAdd((SimpleDocumentFeature)makeNativeFeature(new_feature, true)) == null)
failed.append(new_feature.getKey().getKeyString()+"\n");
}
else
{
add(makeNativeFeature(new_feature, true));
final Object docFeature = makeNativeFeature(new_feature, true);
if(docFeature instanceof SimpleDocumentFeature[])
{
SimpleDocumentFeature[] docFeatures = (SimpleDocumentFeature[])docFeature;
for(int i=0; i<docFeatures.length; i++)
add((SimpleDocumentFeature)docFeatures[i]);
}
else
add((SimpleDocumentFeature)docFeature);
}
}
catch(ReadOnlyException e)
......@@ -583,7 +590,7 @@ abstract public class SimpleDocumentEntry
}
final SimpleDocumentFeature native_feature =
makeNativeFeature(feature, false);
(SimpleDocumentFeature)makeNativeFeature(feature, false);
final FeatureTable feature_table = getFeatureTable();
feature_table.add(native_feature);
......@@ -679,7 +686,7 @@ abstract public class SimpleDocumentEntry
}
final SimpleDocumentFeature native_feature =
makeNativeFeature(feature, false);
(SimpleDocumentFeature)makeNativeFeature(feature, false);
if(qualifiers_fixed)
{
......@@ -1230,7 +1237,7 @@ abstract public class SimpleDocumentEntry
* The feature should not be in an Entry when this method is called.
* @param copy if true then always make a new copy of the Feature.
**/
protected abstract SimpleDocumentFeature
protected abstract Object
makeNativeFeature(final Feature feature,
final boolean copy);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment