diff --git a/etc/versions b/etc/versions index 31b100847539325d3bc50615cd3aca2fdb9a675a..97db435897db12230c946ee112de9e600febb3b6 100644 --- a/etc/versions +++ b/etc/versions @@ -1,4 +1,4 @@ -Artemis Release 16.0.7 -ACT Release 13.0.7 +Artemis Release 16.0.8 +ACT Release 13.0.8 DNAPlotter Release 1.11 BamView 1.2.13 \ No newline at end of file diff --git a/uk/ac/sanger/artemis/io/GenbankTblOutputStream.java b/uk/ac/sanger/artemis/io/GenbankTblOutputStream.java index 82ae21efce07f97c3d12f5e84c3d19c5660a2886..4083fac396c40c28926c0a0ba48d290a30f59b21 100644 --- a/uk/ac/sanger/artemis/io/GenbankTblOutputStream.java +++ b/uk/ac/sanger/artemis/io/GenbankTblOutputStream.java @@ -38,14 +38,12 @@ import uk.ac.sanger.artemis.FeatureVector; import uk.ac.sanger.artemis.util.FileDocument; import uk.ac.sanger.artemis.util.StringVector; - /** * Handle writing tbl format: * http://www.ncbi.nlm.nih.gov/Sequin/table.html */ public class GenbankTblOutputStream { - /** * Write out an entry as tbl format. * @param entry @@ -76,10 +74,9 @@ public class GenbankTblOutputStream { final Writer writer = fileDocument.getWriter(); writer.write(">Feature "+entry.getName()+"\n"); - + final FeatureVector features = entry.getAllFeatures(); final EntryInformation entry_information = entry.getEntryInformation (); - int count = 0; for(int i=0; i<features.size(); i++) { @@ -88,7 +85,7 @@ public class GenbankTblOutputStream continue; if(count > 0) writer.write("\n"); - + count++; writeRanges(feature, writer); writeQualifiers(feature, entry_information, writer); @@ -113,26 +110,93 @@ public class GenbankTblOutputStream final RangeVector ranges = feature.getLocation().getRanges(); if(!feature.isForwardFeature() && ranges.size() > 1) ranges.reverse(); - - Range r = (Range)ranges.elementAt(0); - if(feature.isForwardFeature()) - writer.write(r.getStart()+"\t"+r.getEnd()); + + boolean isStartPartial = false; + boolean isEndPartial = false; + if(feature.getEmblFeature() instanceof GFFStreamFeature) + { + try + { + if(feature.getQualifierByName("Start_range") != null) + isStartPartial = true; + if(feature.getQualifierByName("End_range") != null) + isEndPartial = true; + } + catch (InvalidRelationException e){} + } else - writer.write(r.getEnd()+"\t"+r.getStart()); - + { + if(feature.getLocation().isPartial(true)) // 5prime + { + if(feature.isForwardFeature()) + isStartPartial = true; + else + isEndPartial = true; + } + if(feature.getLocation().isPartial(false)) // 3prime + { + if(feature.isForwardFeature()) + isEndPartial = true; + else + isStartPartial = true; + } + } + + writer.write( getPositionsStr(feature, ranges.elementAt(0), + isStartPartial, isEndPartial) ); writer.write("\t"+feature.getKey().getKeyString()); for(int j=1; j<ranges.size(); j++) { writer.write("\n"); - r = (Range)ranges.elementAt(j); - if(feature.isForwardFeature()) - writer.write(r.getStart()+"\t"+r.getEnd()); - else - writer.write(r.getEnd()+"\t"+r.getStart()); + writer.write( getPositionsStr(feature, ranges.elementAt(j), + isStartPartial, isEndPartial) ); } } + /** + * Get the start and end positions as a tab delimited string + * @param feature + * @param r + * @param isStartRangePartial + * @param isEndRangePartial + * @return + */ + private static String getPositionsStr( + final Feature feature, + final Range r, + final boolean isStartPartial, + final boolean isEndPartial) + { + boolean firstBase; + boolean lastBase; + final int low_marker = feature.getFirstBaseMarker().getPosition(); + final int high_marker = feature.getLastBaseMarker().getPosition(); + String low_pos; + String high_pos; + if(feature.isForwardFeature()) + { + firstBase = (r.getStart() == low_marker); + lastBase = (r.getEnd() == high_marker); + low_pos = Integer.toString(r.getStart()); + high_pos = Integer.toString(r.getEnd()); + } + else + { + firstBase = (r.getEnd() == high_marker); + lastBase = (r.getStart() == low_marker); + low_pos = Integer.toString(r.getEnd()); + high_pos = Integer.toString(r.getStart()); + } + + // set partials + if(firstBase && isStartPartial) + low_pos = (feature.isForwardFeature() ? "<" : ">")+low_pos; + if(lastBase && isEndPartial) + high_pos = (feature.isForwardFeature() ? ">" : "<")+high_pos; + return low_pos+"\t"+high_pos; + } + /** * Write out qualifiers * @param feature diff --git a/uk/ac/sanger/artemis/util/DatabaseDocument.java b/uk/ac/sanger/artemis/util/DatabaseDocument.java index f96025548a42d33a4f8cf268088ec0fe0bccb1dc..d3ff19cd895b06430a01936c9fffe0c9a5b1343f 100644 --- a/uk/ac/sanger/artemis/util/DatabaseDocument.java +++ b/uk/ac/sanger/artemis/util/DatabaseDocument.java @@ -1661,10 +1661,10 @@ public class DatabaseDocument extends Document if(showDbId) attr_buff.append("GOid="+dbXRef.getDb().getName() + ":" + dbXRef.getAccession() + "%3B"); - + attr_buff.append("term="+ GFF3Encoder.encode(feature_cvterm.getCvTerm().getName())+"%3B"); - + // PMID int nfound_pub = 0; if(feature_cvterm.getPub() != null && @@ -1672,62 +1672,68 @@ public class DatabaseDocument extends Document !feature_cvterm.getPub().getUniqueName().equalsIgnoreCase("NULL")) { Pub pub = feature_cvterm.getPub(); - attr_buff.append("db_xref="+ - pub.getUniqueName()); + attr_buff.append("db_xref="+pub.getUniqueName()); nfound_pub++; } - - if(featureCvTermPubs != null && - featureCvTermPubs.size() > 0) + + if(featureCvTermPubs != null && featureCvTermPubs.size() > 0) { for(FeatureCvTermPub featureCvTermPub: featureCvTermPubs) { if(feature_cvterm.getFeatureCvTermId() != featureCvTermPub.getFeatureCvTerm().getFeatureCvTermId()) continue; - - if(nfound_pub == 0) - attr_buff.append("db_xref="); - else if(nfound_pub > 0) - attr_buff.append("|"); + attr_buff.append((nfound_pub == 0 ? "db_xref=" : "|")); attr_buff.append(featureCvTermPub.getPub().getUniqueName()); nfound_pub++; } } - + + // GO_REF is stored as a dbxref and displayed in the dbxref column + if(featureCvTermDbXRefs != null && featureCvTermDbXRefs.size() > 0 ) + { + for(FeatureCvTermDbXRef featureCvTermDbXRef: featureCvTermDbXRefs) + { + if(feature_cvterm.getFeatureCvTermId() != + featureCvTermDbXRef.getFeatureCvTerm().getFeatureCvTermId()) + continue; + + DbXRef fc_dbXRef = featureCvTermDbXRef.getDbXRef(); + if(!fc_dbXRef.getDb().getName().equals("GO_REF")) + continue; + attr_buff.append((nfound_pub == 0 ? "db_xref=" : "|")); + attr_buff.append(fc_dbXRef.getDb().getName()+":"); + attr_buff.append(fc_dbXRef.getAccession()); + nfound_pub++; + } + } if(nfound_pub > 0) attr_buff.append("%3B"); - - if(featureCvTermDbXRefs != null && - featureCvTermDbXRefs.size() > 0 ) + + if(featureCvTermDbXRefs != null && featureCvTermDbXRefs.size() > 0 ) { int nfound = 0; for(FeatureCvTermDbXRef featureCvTermDbXRef : featureCvTermDbXRefs) { if(feature_cvterm.getFeatureCvTermId() != featureCvTermDbXRef.getFeatureCvTerm().getFeatureCvTermId()) - { continue; - } - if(nfound == 0) - attr_buff.append("with="); - else if(nfound > 0) - attr_buff.append("|"); - DbXRef fc_dbXRef = featureCvTermDbXRef.getDbXRef(); + if(fc_dbXRef.getDb().getName().equals("GO_REF")) + continue; + attr_buff.append((nfound == 0 ? "with=" : "|")); attr_buff.append(fc_dbXRef.getDb().getName()+":"); attr_buff.append(fc_dbXRef.getAccession()); nfound++; } - if(nfound > 0) attr_buff.append("%3B"); - } - List<FeatureCvTermProp> feature_cvtermprops = (List<FeatureCvTermProp>)feature_cvterm.getFeatureCvTermProps(); + List<FeatureCvTermProp> feature_cvtermprops = + (List<FeatureCvTermProp>)feature_cvterm.getFeatureCvTermProps(); for(int i = 0; i < feature_cvtermprops.size(); i++) { FeatureCvTermProp feature_cvtermprop = feature_cvtermprops.get(i); @@ -1741,7 +1747,6 @@ public class DatabaseDocument extends Document if(i < feature_cvtermprops.size()-1) attr_buff.append("%3B"); } - attr_buff.append(";"); }