[Biojava-l] [BioSQL-l] hierachy of features

Martina boehme at mpiib-berlin.mpg.de
Wed May 4 05:50:29 EDT 2005


I get differend results on differend runs. The hierachy of features 
changes (not only the order) - with the same code. I'm using bioJava Live.

I do:

delete(db, "AF100928");
create(db, sequence);
retrieveSeq(db, "AF100928");

and get:

deleting AF100928
adding a sequence
1
retrieving AF100928
AF100928 contains 1 features
Source: ncbi Type: gen contains: 2
Second Level: Source: AIF Type: siRNA contains: 1
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0


OR, on some runs (at least one in 10) I get:

deleting AF100928
adding a sequence
1
retrieving AF100928
AF100928 contains 2 features
Source: 1 Type: AIF-1 contains: 0
Project : [2572/73, A]
Source: ncbi Type: gen contains: 8
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0
Second Level: Source: AIF Type: siRNA contains: 0
Second Level: Source: AIF 5`450 / AIF 3`682 Type: Amplicon contains: 0

Just in case, I attached the source. I can see only 4 features in 
Table seqfeature - but that might not be the right table to look into?
Can anybody help me with this?

Thanks
Martina

-------------- next part --------------

import org.biojava.bio.BioException;
import org.biojava.bio.symbol.*;
import org.biojava.bio.*;
import org.biojava.bio.seq.*;
import org.biojava.utils.*;
import org.biojava.bio.seq.DNATools;
import org.biojava.bio.seq.Sequence;
import org.biojava.bio.seq.db.biosql.BioSQLSequenceDB;
import org.biojava.utils.ChangeVetoException;
import org.biojava.bio.seq.io.SeqIOTools;
import java.io.*;
import java.sql.SQLException;
import java.util.*;

/**
 * <p>
 * Tests a connection to a BioSQLSequenceDB and a simple Sequence write, read
 * and delete
 * </p>
 */
public class bioSqlTest {
	public static void main(String[] args) {
		// url format depends on your jdbc driver
		String dbURL = "jdbc:mysql://somnus/test";
		String dbUser = "xxxxxxx";
		String dbPass = "xxxxx";
		// we will connect to a biodatabase called test
		String biodatabase = "test";
		// or create one if it doesn't exist
		boolean createIfMissing = true;
		try {
			// load a JDBC driver
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException ex) {
			System.out
					.println("Cannot find DB driver, is it on your classpath?");
		}
		try {
			// create a connection
			BioSQLSequenceDB db = new BioSQLSequenceDB(dbURL, dbUser, dbPass,
					biodatabase, createIfMissing);
			String sequence = "agaggaaagggaaggaggaggtcccgaatagcggtcgccgaaatgttccggtgtggaggcctggcggcgggtgctttgaagcagaagctggtgcccttggtgcggaccgtgtgcgtccgaagcccgaggcagaggaaccggctcccaggcaacttgttccagcgatggcatgttcctctagaactccagatgacaagacaaatggctagctctggtgcatcagggggcaaaatcgataattctgtgttagtccttattgtgggcttatcaacagtaggagctggtgcctatgcctacaagactatgaaagaggacgaaaaaagatacaatgaaagaatttcagggttagggctgacaccagaacagaaacagaaaaaggccgcgttatctgcttcagaaggagaggaagttcctcaagacaaggcgccaagtcatgttcctttcctgctaattggtggaggcacagctgcttttgctgcagccagatccatccgggctcgggatcctggggccagggtactgattgtatctgaagatcctgagctgccgtacatgcgacctcctctttcaaaagaactgtggttttcagatgacccaaatgtcacaaagacactgcgattcaaacagtggaatggaaaagagagaagcatatatttccagccaccttctttctatgtctctgctcaggacctgcctcatattgagaatggtggtgtggctgtcctcactgggaagaaggtagtacagctggatgtgagagacaacatggtgaaacttaatgatggctctcaaataacctatgaaaagtgcttgattgcaacaggaggtactccaagaagtctgtctgccattgatagggctggagcagaggtgaagagtagaacaacgcttttcagaaagattggagactttagaagcttggagaagatttcacgggaagtcaaatcaattacgattatcggtgggggcttccttggtagcgaactggcctgtgctcttggcagaaaggctcgagccttgggcacagaagtgattcaactcttccccgagaaaggaaatatgggaaagatcctccccgaatacctcagcaactggaccatggaaaaagtcagacgagagggggttaaggtgatgcccaatgctattgtgcaatccgttggagtcagcagtggcaagttacttatcaagctgaaagacggcaggaaggtagaaactgaccacatagtggcagctgtgggcctggagcccaatgttgagttggccaagactggtggcctggaaatagactcagattttggtggcttccgggtaaatgcagagctacaagcacgctctaacatctgggtggcaggagatgctgcatgcttctacgatataaagttgggaaggaggcgggtagagcaccatgatcacgctgttgtgagtggaagattggctggagaaaatatgactggagctgctaagccgtactggcatcagtcaatgttctggagtgatttgggccccgatgttggctatgaagctattggtcttgtggacagtagtttgcccacagttggtgtttttgcaaaagcaactgcacaagacaaccccaaatctgccacagagcagtcaggaactggtatccgatcagagagtgagacagagtccgaggcctcagaaattactattcctcccagcaccccggcagttccacaggctcccgtccagggggaggactacggcaaaggtgtcatcttctacctcagggacaaagtggtcgtggggattgtgctatggaacatctttaaccgaatgccaatagcaaggaagatcattaaggacggtgagcagcatgaagatctcaatgaagtagccaaactattcaacattcatgaagactgaagccccacagtggaattggcaa";
			sequence = sequence.replace(" ", "");
			delete(db, "AF100928");
			create(db, sequence);
			retrieveSeq(db, "AF100928");

		}
		// } catch (ChangeVetoException ex) {
		// System.err.println("Cannot add Sequence, is the DB locked?");
		// System.exit(1);
		//
		// }

		catch (Exception ex) {
			ex.printStackTrace();
			System.exit(1);
		}
	}

	private static void create(BioSQLSequenceDB db, String sequence)
			throws IllegalSymbolException, IllegalArgumentException,
			ChangeVetoException, IndexOutOfBoundsException, BioException {
		Sequence seq = DNATools.createDNASequence(sequence, "AF100928");
		// add annotation
		seq.getAnnotation().setProperty("Lab-Genname", "AIF");
		seq.getAnnotation().setProperty("gi", "4323586");
		seq.getAnnotation()
				.setProperty("genename", "apoptosis-inducing factor");
		seq.getAnnotation().setProperty("organism", "Homo sapiens");
		seq.getAnnotation().setProperty("protein-id", "AAD16436.1");
		// fill the template
		Feature.Template templSeq = new Feature.Template();
		templSeq.source = "ncbi";
		// templSeq.strand = StrandedFeature.UNKNOWN;
		templSeq.type = "gen";
		templSeq.location = Location.empty;
		Feature seqF = seq.createFeature(templSeq);
		// create siRNA
		StrandedFeature.Template templSt = new StrandedFeature.Template();
		templSt.location = new RangeLocation(201, 221);
		templSt.strand = StrandedFeature.POSITIVE;
		templSt.source = "AIF"; // =>id
		templSt.type = "siRNA"; // oder shRNA oder cellline?
		Annotation annoSiRNA = new SimpleAnnotation();
		annoSiRNA.setProperty("abbreviation", "AIF");
		annoSiRNA.setProperty("no", 3);
		templSt.annotation = annoSiRNA;
		Feature sf = seqF.createFeature(templSt);
		// create charge
		Feature.Template charge = new Feature.Template();
		charge.type = "AIF-1"; // Name, so wie er in der siRNA Liste steht
		charge.source = "1"; // Erste Synthese
		charge.location = Location.empty;
		Annotation chargeAnno = new SmallAnnotation();
		chargeAnno.setProperty("Batchno", "2572/73");
		chargeAnno.setProperty("Project", "A");
		charge.annotation = chargeAnno;
		Feature cf = sf.createFeature(charge);
		// create Amplicon
		StrandedFeature.Template templ = new StrandedFeature.Template();
		templ.location = new RangeLocation(72, 92);
		templ.source = "AIF 5`450 / AIF 3`682";
		templ.type = "Amplicon";
		templ.strand = StrandedFeature.UNKNOWN;
		Annotation annoAmplicon = new SimpleAnnotation();
		annoAmplicon.setProperty("Provider", "Invitrogen");
		annoAmplicon.setProperty("designed by", "Chris");
		annoAmplicon.setProperty("Stock-Box/Position", "rtS-A3/A5 + rtS-A3/A6");
		annoAmplicon.setProperty("Arbeitslösung", "rtArb-A1/C3");
		// templ.annotation = annoAmplicon;
		Feature af = seqF.createFeature(templ);

		System.out.println("adding a sequence");
		System.out.println(seq.countFeatures());
		db.addSequence(seq);
		// seq = null; //cannot remove unless there are no references to the
		// sequence
	}

	private static void delete(BioSQLSequenceDB db, String name) {

		try {
			// delete the record

			System.out.println("deleting " + name);
			db.removeSequence(name);
		} catch (Exception ex) {
			System.err.println("Cannot remove " + name + " is the DB locked?");
		}
	}

	private static void retrieveSeq(BioSQLSequenceDB db, String seqName)
			throws BioException, NoSuchElementException {
		Sequence seq;
		System.out.println("retrieving " + seqName);
		seq = db.getSequence(seqName);
		// try {

		System.out.println(seq.getName() + " contains " + seq.countFeatures()
				+ " features");
		for (Iterator<Feature> i = seq.features(); i.hasNext();) {
			Feature f = (Feature) i.next();
			/* Print only 'toplevel' features  */
			System.out.println("Source: " + f.getSource() + " Type: "
					+ f.getType() + " contains: " + f.countFeatures());

			Annotation anno = f.getAnnotation();

			// print each key value pair
			for (Iterator it = anno.keys().iterator(); it.hasNext();) {
				Object key = it.next();
				System.out.println(key + " : " + anno.getProperty(key));
			}

			for (Iterator<Feature> it = f.features(); it.hasNext();) {
				Feature fs = (Feature) it.next();
				// print second level features
				System.out.println("Second Level: Source: " + fs.getSource()
						+ " Type: " + fs.getType() + " contains: "
						+ fs.countFeatures());
			}
		}

	}
}


More information about the Biojava-l mailing list