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

join exons and add parents to GFF generated from database

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@3201 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent b2b6725d
No related branches found
No related tags found
No related merge requests found
......@@ -294,8 +294,8 @@ public class DatabaseEntrySource implements EntrySource
{
DatabaseDocumentEntry db_entry = null;
final EntryInformation entry_information =
new SimpleEntryInformation(Options.getArtemisEntryInformation());
// final EntryInformation entry_information =
// new SimpleEntryInformation(Options.getArtemisEntryInformation());
if(read_only)
{
......@@ -305,7 +305,7 @@ public class DatabaseEntrySource implements EntrySource
DatabaseDocument doc = new DatabaseDocument(location, id, progress_listener);
// DatabaseDocument doc = new DatabaseDocument("jdbc:postgresql://localhost:13001/chadoCVS?user=es2",
// id, progress_listener);
db_entry = new DatabaseDocumentEntry(entry_information, doc);
db_entry = new DatabaseDocumentEntry(doc);
}
final Bases real_bases;
......
......@@ -34,15 +34,14 @@ import java.io.*;
* relational database entry
**/
public class DatabaseDocumentEntry extends SimpleDocumentEntry
public class DatabaseDocumentEntry extends GFFDocumentEntry
implements DocumentEntry
{
public DatabaseDocumentEntry(final EntryInformation entry_information,
final Document doc)
public DatabaseDocumentEntry(final Document doc)
throws EntryInformationException, IOException
{
super(entry_information, doc, null);
super(doc,null);
}
/**
......
......@@ -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.15 2005-07-15 10:33:56 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFDocumentEntry.java,v 1.16 2005-07-18 19:20:25 tjc Exp $
*/
package uk.ac.sanger.artemis.io;
......@@ -36,7 +36,7 @@ import java.util.Vector;
* A DocumentEntry that can read an GFF entry from a Document.
*
* @author Kim Rutherford
* @version $Id: GFFDocumentEntry.java,v 1.15 2005-07-15 10:33:56 tjc Exp $
* @version $Id: GFFDocumentEntry.java,v 1.16 2005-07-18 19:20:25 tjc Exp $
**/
public class GFFDocumentEntry extends SimpleDocumentEntry
......@@ -166,7 +166,8 @@ public class GFFDocumentEntry extends SimpleDocumentEntry
this_feature.getQualifierByName("Parent").getValues();
group_name = values.elementAt(0);
if(this_feature.getQualifierByName("ID") != null)
if(this_feature.getQualifierByName("ID") != null &&
!key.equals("exon"))
{
values =
this_feature.getQualifierByName("ID").getValues();
......
......@@ -199,18 +199,24 @@ public class DatabaseDocument extends Document
private String getGFF(Connection conn, String parentFeatureID)
throws java.sql.SQLException
{
Statement st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
String sql = "SELECT strand, fmin, fmax, uniquename, feature.type_id, featureprop.type_id AS prop_type_id, value"+
" FROM feature, featureloc, featureprop WHERE srcfeature_id = "+parentFeatureID+
" and featureloc.feature_id=featureprop.feature_id"+
" and featureloc.feature_id=feature.feature_id ORDER BY uniquename";
// String sql = "SELECT feature_id, strand, fmin, fmax, uniquename, feature.type_id, featureprop.type_id AS prop_type_id, value"+
// " FROM feature, featureloc, featureprop WHERE srcfeature_id = "+parentFeatureID+
// " and featureloc.feature_id=featureprop.feature_id"+
// " and featureloc.feature_id=feature.feature_id";
String sql = "SELECT feature.feature_id, object_id, strand, fmin, fmax, uniquename, feature.type_id, "+
" featureprop.type_id AS prop_type_id, featureprop.value FROM feature, featureloc, featureprop, feature_relationship "+
" WHERE srcfeature_id = "+parentFeatureID+" and featureloc.feature_id=featureprop.feature_id and "+
" featureloc.feature_id=feature.feature_id and feature_relationship.subject_id=feature.feature_id";
appendToLogFile(sql,sqlLog);
ResultSet rs = st.executeQuery(sql);
StringBuffer cdsBuffer = new StringBuffer();
String parentFeature = getFeatureName(parentFeatureID,conn);
int loop = 1;
Hashtable hstore = new Hashtable();
while(rs.next())
{
......@@ -223,6 +229,13 @@ public class DatabaseDocument extends Document
String typeName = getCvtermName(conn,type_id);
String propTypeName = getCvtermName(conn,prop_type_id);
String feature_id = rs.getString("feature_id");
hstore.put(feature_id, name);
String parent_id = rs.getString("object_id");
if(parent_id != null && hstore.containsKey(parent_id))
parent_id = (String)hstore.get(parent_id);
// make gff format
cdsBuffer.append(parentFeature+"\t"); // seqid
cdsBuffer.append("chado\t"); // source
......@@ -237,6 +250,9 @@ public class DatabaseDocument extends Document
cdsBuffer.append(".\t"); // phase
cdsBuffer.append("ID="+name+";"+propTypeName+"="+rs.getString("value")); // attributes
if(parent_id != null)
cdsBuffer.append(";Parent="+parent_id);
int rewind = 0;
while(rs.next() && rs.getString("uniquename").equals(name))
{
......
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