[Biojava-l] nested features
Richard HOLLAND
hollandr at gis.a-star.edu.sg
Wed May 18 22:33:59 EDT 2005
Just to get this straight, if I follow your code correctly, then the second example output you should be seeing is the correct one. Could you confirm that this is what you are expecting? At least then it gives us something to work towards as a definite known correct answer.
It would also be helpful if you could provide, for each of the two cases, the contents of the seqfeature and seqfeature_relationship tables. You don't need to provide them all. Just find out the bioentry_id of the inserted sequence (look it up in the 'bioentry' table using the 'name' column to look for your sequence name), then record all the rows from seqfeature with bioentry_id being that value, and all rows from seqfeature_relationship where either subject_seqfeature_id or object_seqfeature_id matches any of the seqfeature_id values you just got from the seqfeature table.
In other words (assuming Oracle, but similar queries will work elsewhere):
select seqfeature.*
from seqfeature, bioentry
where seqfeature.bioentry_id = bioentry.bioentry_id
and bioentry.name = 'AF100928';
select seqfeature_relationship.*
from seqfeature_relationship, seqfeature, bioentry
where (subject_seqfeature_id = seqfeature.seqfeature_id
or object_seqfeature_id = seqfeature.seqfeature_id)
and seqfeature.bioentry_id = bioentry.bioentry_id
and bioentry.name = 'AF100928';
Also could you change all the "Iterator<Feature>" references in your test code to just "Iterator" as BioJava does not use Java 1.5 internally and I'm not sure what effect genericising the iterator might have (Java 1.5 can do funny things due to the effect of what they call erasure). This probably won't fix it, but it's worth a try.
cheers,
Richard
Richard Holland
Bioinformatics Specialist
GIS extension 8199
---------------------------------------------
This email is confidential and may be privileged. If you are not the intended recipient, please delete it and notify us immediately. Please do not copy or use it for any purpose, or disclose its content to any other person. Thank you.
---------------------------------------------
> -----Original Message-----
> From: biojava-l-bounces at portal.open-bio.org
> [mailto:biojava-l-bounces at portal.open-bio.org] On Behalf Of Martina
> Sent: Wednesday, May 18, 2005 6:08 PM
> To: biojava-l at biojava.org
> Subject: [Biojava-l] nested features
>
>
> Hi,
> I'm still having problems with nested features. I know that the order
> in which they are retrieved is not constant, but the hierachy should
> be. I do:
>
> delete(db, "AF100928");
> create(db, sequence);
> retrieveSeq(db, "AF100928");
>
> and 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
>
>
> OR, on some runs (at least one in 10) I 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
>
> I can't see any difference in the biosql db (MySql), but I don't know
> where to look exactly.
> If I don't delete the record, just retrieve it on different runs, the
> output stays the same. I'm using biojava live from last month.
> I would be very grateful if someone could help me with this!
>
> Martina
>
> I add it like this:
>
> 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";
> 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);
> }
>
> and here it gets printed:
>
> private static void retrieveSeq(BioSQLSequenceDB db, String seqName)
> throws BioException, NoSuchElementException {
> Sequence seq;
> System.out.println("retrieving " + seqName);
> seq = db.getSequence(seqName);
> System.out.println(seq.getName() + " contains " + seq.countFeatures()
> + " features");
> for (Iterator<Feature> i = seq.features(); i.hasNext();) {
> Feature f = (Feature) i.next();
> 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();
> System.out.println("Second Level: Source: " +
> fs.getSource()
> + " Type: " + fs.getType() + "
> contains: "
> + fs.countFeatures());
> }
> }
> _______________________________________________
> Biojava-l mailing list - Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
>
More information about the Biojava-l
mailing list