X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFeaturesFile.java;h=821384a600dc2176a332ef00e5bbd18452fc5d27;hb=b87512d6e28a2a93ea2f08dcfbee320856c5c8de;hp=d2a9b0ab342be6408585b61e1fd7db3a2ea9311b;hpb=ab0e5f2223a993371761baf240d815abdfcbb950;p=jalview.git diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index d2a9b0a..821384a 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -88,6 +88,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI private static final String ID_NOT_SPECIFIED = "ID_NOT_SPECIFIED"; + private static final String NOTE = "Note"; + protected static final String GFF_VERSION = "##gff-version"; private AlignmentI lastmatchedAl = null; @@ -591,6 +593,14 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI .getDisplayedFeatureCols(); Map featureFilters = fr.getFeatureFilters(); + // BH check this is out? +// if (!includeNonPositional +// && (visibleColours == null || visibleColours.isEmpty())) +// { +// // no point continuing. +// return "No Features Visible"; +// } + /* * write out feature colours (if we know them) */ @@ -908,7 +918,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @param sequenceName * @param sequenceFeature */ - protected void formatJalviewFeature( + protected String formatJalviewFeature( StringBuilder out, String sequenceName, SequenceFeature sequenceFeature) { @@ -962,6 +972,8 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI out.append(sequenceFeature.score); } out.append(newline); + + return out.toString(); } /** @@ -973,14 +985,15 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI AlignViewportI av = getViewport(); if (av != null) { - if (av.getAlignment() != null) + AlignmentI a = av.getAlignment(); + if (a != null) { - dataset = av.getAlignment().getDataset(); + dataset = a.getDataset(); } if (dataset == null) { // working in the applet context ? - dataset = av.getAlignment(); + dataset = a; } } else @@ -1020,11 +1033,9 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * Returns features output in GFF2 format * * @param sequences - * the sequences whose features are to be - * output + * the sequences whose features are to be output * @param visible - * a map whose keys are the type names of - * visible features + * a map whose keys are the type names of visible features * @param visibleFeatureGroups * @param includeNonPositionalFeatures * @param includeComplement @@ -1036,7 +1047,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI { FeatureRenderer fr2 = null; if (includeComplement) - { + { AlignViewportI comp = fr.getViewport().getCodingComplement(); fr2 = Desktop.getAlignFrameFor(comp).getFeatureRenderer(); } @@ -1063,6 +1074,7 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI { features.addAll(seq.getFeatures().getPositionalFeatures(types)); } + for (SequenceFeature sf : features) { if (sf.isNonPositional() || fr.isVisible(sf)) @@ -1099,34 +1111,34 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI private void formatGffFeature(StringBuilder out, SequenceI seq, SequenceFeature sf) { - String source = sf.featureGroup; - if (source == null) - { - source = sf.getDescription(); - } - - out.append(seq.getName()); - out.append(TAB); - out.append(source); - out.append(TAB); - out.append(sf.type); - out.append(TAB); - out.append(sf.begin); - out.append(TAB); - out.append(sf.end); - out.append(TAB); - out.append(sf.score); - out.append(TAB); - - int strand = sf.getStrand(); - out.append(strand == 1 ? "+" : (strand == -1 ? "-" : ".")); - out.append(TAB); + String source = sf.featureGroup; + if (source == null) + { + source = sf.getDescription(); + } - String phase = sf.getPhase(); - out.append(phase == null ? "." : phase); + out.append(seq.getName()); + out.append(TAB); + out.append(source); + out.append(TAB); + out.append(sf.type); + out.append(TAB); + out.append(sf.begin); + out.append(TAB); + out.append(sf.end); + out.append(TAB); + out.append(sf.score); + out.append(TAB); + + int strand = sf.getStrand(); + out.append(strand == 1 ? "+" : (strand == -1 ? "-" : ".")); + out.append(TAB); + + String phase = sf.getPhase(); + out.append(phase == null ? "." : phase); if (sf.otherDetails != null && !sf.otherDetails.isEmpty()) - { + { Map map = sf.otherDetails; formatAttributes(out, map); } @@ -1237,11 +1249,11 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * format) * * @param alignedRegions - * a list of "Align fromStart toStart fromCount" + * a list of "Align fromStart toStart fromCount" * @param mapIsFromCdna - * if true, 'from' is dna, else 'from' is protein + * if true, 'from' is dna, else 'from' is protein * @param strand - * either 1 (forward) or -1 (reverse) + * either 1 (forward) or -1 (reverse) * @return * @throws IOException */ @@ -1376,6 +1388,39 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI return seq; } + // BH! check that we did not lose something here. +// /** +// * Process the 'column 9' data of the GFF file. This is less formally defined, +// * and its interpretation will vary depending on the tool that has generated +// * it. +// * +// * @param attributes +// * @param sf +// */ +// protected void processGffColumnNine(String attributes, SequenceFeature sf) +// { +// sf.setAttributes(attributes); +// +// /* +// * Parse attributes in column 9 and add them to the sequence feature's +// * 'otherData' table; use Note as a best proxy for description +// */ +// char nameValueSeparator = gffVersion == 3 ? '=' : ' '; +// // TODO check we don't break GFF2 values which include commas here +// Map> nameValues = GffHelperBase +// .parseNameValuePairs(attributes, ";", nameValueSeparator, ","); +// for (Entry> attr : nameValues.entrySet()) +// { +// String values = StringUtils.listToDelimitedString(attr.getValue(), +// "; "); +// sf.setValue(attr.getKey(), values); +// if (NOTE.equals(attr.getKey())) +// { +// sf.setDescription(values); +// } +// } +// } + /** * After encountering ##fasta in a GFF3 file, process the remainder of the * file as FAST sequence data. Any placeholder sequences created during