2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
24 import jalview.api.AlignExportSettingI;
25 import jalview.api.AlignViewportI;
26 import jalview.api.AlignmentViewPanel;
27 import jalview.api.ComplexAlignFile;
28 import jalview.api.FeatureRenderer;
29 import jalview.api.FeatureSettingsModelI;
30 import jalview.api.FeaturesDisplayedI;
31 import jalview.bin.BuildDetails;
32 import jalview.datamodel.AlignmentAnnotation;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.Annotation;
35 import jalview.datamodel.HiddenColumns;
36 import jalview.datamodel.HiddenSequences;
37 import jalview.datamodel.Sequence;
38 import jalview.datamodel.SequenceFeature;
39 import jalview.datamodel.SequenceGroup;
40 import jalview.datamodel.SequenceI;
41 import jalview.json.binding.biojson.v1.AlignmentAnnotationPojo;
42 import jalview.json.binding.biojson.v1.AlignmentPojo;
43 import jalview.json.binding.biojson.v1.AnnotationDisplaySettingPojo;
44 import jalview.json.binding.biojson.v1.AnnotationPojo;
45 import jalview.json.binding.biojson.v1.ColourSchemeMapper;
46 import jalview.json.binding.biojson.v1.SequenceFeaturesPojo;
47 import jalview.json.binding.biojson.v1.SequenceGrpPojo;
48 import jalview.json.binding.biojson.v1.SequencePojo;
49 import jalview.renderer.seqfeatures.FeatureColourFinder;
50 import jalview.schemes.ColourSchemeProperty;
51 import jalview.schemes.JalviewColourScheme;
52 import jalview.schemes.ResidueColourScheme;
53 import jalview.util.ColorUtils;
54 import jalview.util.Format;
55 import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
57 import java.awt.Color;
58 import java.io.IOException;
59 import java.io.Reader;
60 import java.util.ArrayList;
61 import java.util.Hashtable;
62 import java.util.Iterator;
63 import java.util.List;
64 import java.util.Vector;
66 import org.json.simple.JSONArray;
67 import org.json.simple.JSONObject;
68 import org.json.simple.parser.JSONParser;
70 public class JSONFile extends AlignFile implements ComplexAlignFile
72 private static String version = new BuildDetails().getVersion();
74 private String webstartUrl = "http://www.jalview.org/services/launchApp";
76 private String application = "Jalview";
78 private String globalColourScheme;
80 private boolean showSeqFeatures;
82 private Hashtable<String, Sequence> seqMap;
84 private FeaturesDisplayedI displayedFeatures;
86 private FeatureRenderer fr;
88 private HiddenColumns hiddenColumns;
90 private List<String> hiddenSeqRefs;
92 private ArrayList<SequenceI> hiddenSequences;
94 private final static String TCOFFEE_SCORE = "TCoffeeScore";
101 public JSONFile(FileParse source) throws IOException
106 public JSONFile(String inFile, DataSourceType sourceType)
109 super(inFile, sourceType);
113 public void parse() throws IOException
120 public String print(SequenceI[] sqs, boolean jvsuffix)
122 String jsonOutput = null;
125 AlignmentPojo jsonAlignmentPojo = new AlignmentPojo();
126 AlignExportSettingI exportSettings = getExportSettings();
128 // if no export settings were supplied use the following with all values
129 // defaulting to true
130 if (exportSettings == null)
132 exportSettings = new AlignExportSettingI()
135 public boolean isExportHiddenSequences()
141 public boolean isExportHiddenColumns()
147 public boolean isExportGroups()
153 public boolean isExportFeatures()
159 public boolean isExportAnnotations()
165 public boolean isCancelled()
173 for (SequenceI seq : sqs)
175 StringBuilder name = new StringBuilder();
176 name.append(seq.getName()).append("/").append(seq.getStart())
177 .append("-").append(seq.getEnd());
178 SequencePojo jsonSeqPojo = new SequencePojo();
179 jsonSeqPojo.setId(String.valueOf(seq.hashCode()));
180 jsonSeqPojo.setOrder(++count);
181 jsonSeqPojo.setEnd(seq.getEnd());
182 jsonSeqPojo.setStart(seq.getStart());
183 jsonSeqPojo.setName(name.toString());
184 jsonSeqPojo.setSeq(seq.getSequenceAsString());
185 jsonAlignmentPojo.getSeqs().add(jsonSeqPojo);
187 jsonAlignmentPojo.setGlobalColorScheme(globalColourScheme);
188 jsonAlignmentPojo.getAppSettings().put("application", application);
189 jsonAlignmentPojo.getAppSettings().put("version", version);
190 jsonAlignmentPojo.getAppSettings().put("webStartUrl", webstartUrl);
191 jsonAlignmentPojo.getAppSettings().put("showSeqFeatures",
192 String.valueOf(showSeqFeatures));
194 String[] hiddenSections = getHiddenSections();
195 if (hiddenSections != null)
197 if (hiddenSections[0] != null
198 && exportSettings.isExportHiddenColumns())
200 jsonAlignmentPojo.getAppSettings().put("hiddenCols",
201 String.valueOf(hiddenSections[0]));
203 if (hiddenSections[1] != null
204 && exportSettings.isExportHiddenSequences())
206 jsonAlignmentPojo.getAppSettings().put("hiddenSeqs",
207 String.valueOf(hiddenSections[1]));
211 if (exportSettings.isExportAnnotations())
214 .setAlignAnnotation(annotationToJsonPojo(annotations));
218 // These color schemes require annotation, disable them if annotations
220 if (globalColourScheme
221 .equalsIgnoreCase(JalviewColourScheme.RNAHelices.toString())
222 || globalColourScheme
223 .equalsIgnoreCase(JalviewColourScheme.TCoffee
226 jsonAlignmentPojo.setGlobalColorScheme(ResidueColourScheme.NONE);
230 if (exportSettings.isExportFeatures())
232 jsonAlignmentPojo.setSeqFeatures(sequenceFeatureToJsonPojo(sqs));
235 if (exportSettings.isExportGroups() && seqGroups != null
236 && seqGroups.size() > 0)
238 for (SequenceGroup seqGrp : seqGroups)
240 SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
241 seqGrpPojo.setGroupName(seqGrp.getName());
242 seqGrpPojo.setColourScheme(ColourSchemeProperty
243 .getColourName(seqGrp.getColourScheme()));
244 seqGrpPojo.setColourText(seqGrp.getColourText());
245 seqGrpPojo.setDescription(seqGrp.getDescription());
246 seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes());
247 seqGrpPojo.setDisplayText(seqGrp.getDisplayText());
248 seqGrpPojo.setEndRes(seqGrp.getEndRes());
249 seqGrpPojo.setStartRes(seqGrp.getStartRes());
250 seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved());
251 for (SequenceI seq : seqGrp.getSequences())
253 seqGrpPojo.getSequenceRefs()
254 .add(String.valueOf(seq.hashCode()));
256 jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo);
259 org.json.JSONObject generatedJSon = new org.json.JSONObject(
261 jsonOutput = generatedJSon.toString();
262 return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend",
264 } catch (Exception e)
271 public String[] getHiddenSections()
273 String[] hiddenSections = new String[2];
274 if (getViewport() == null)
279 // hidden column business
280 if (getViewport().hasHiddenColumns())
282 List<int[]> hiddenCols = getViewport().getAlignment()
285 StringBuilder hiddenColsBuilder = new StringBuilder();
286 for (int[] range : hiddenCols)
288 hiddenColsBuilder.append(";").append(range[0]).append("-")
292 hiddenColsBuilder.deleteCharAt(0);
293 hiddenSections[0] = hiddenColsBuilder.toString();
296 // hidden rows/seqs business
297 HiddenSequences hiddenSeqsObj = getViewport().getAlignment()
298 .getHiddenSequences();
299 if (hiddenSeqsObj == null || hiddenSeqsObj.hiddenSequences == null)
301 return hiddenSections;
304 SequenceI[] hiddenSeqs = hiddenSeqsObj.hiddenSequences;
305 StringBuilder hiddenSeqsBuilder = new StringBuilder();
306 for (SequenceI hiddenSeq : hiddenSeqs)
308 if (hiddenSeq != null)
310 hiddenSeqsBuilder.append(";").append(hiddenSeq.hashCode());
313 if (hiddenSeqsBuilder.length() > 0)
315 hiddenSeqsBuilder.deleteCharAt(0);
317 hiddenSections[1] = hiddenSeqsBuilder.toString();
319 return hiddenSections;
322 protected List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
325 displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
326 List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
329 return sequenceFeaturesPojo;
332 FeatureColourFinder finder = new FeatureColourFinder(fr);
334 String[] visibleFeatureTypes = displayedFeatures == null ? null
335 : displayedFeatures.getVisibleFeatures().toArray(
336 new String[displayedFeatures.getVisibleFeatureCount()]);
338 for (SequenceI seq : sqs)
341 * get all features currently visible (and any non-positional features)
343 List<SequenceFeature> seqFeatures = seq.getFeatures().getAllFeatures(
344 visibleFeatureTypes);
345 for (SequenceFeature sf : seqFeatures)
347 SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
348 String.valueOf(seq.hashCode()));
350 String featureColour = (fr == null) ? null : Format
351 .getHexString(finder.findFeatureColour(Color.white, seq,
352 seq.findIndex(sf.getBegin())));
353 int xStart = sf.getBegin() == 0 ? 0
354 : seq.findIndex(sf.getBegin()) - 1;
355 int xEnd = sf.getEnd() == 0 ? 0 : seq.findIndex(sf.getEnd());
356 jsonFeature.setXstart(xStart);
357 jsonFeature.setXend(xEnd);
358 jsonFeature.setType(sf.getType());
359 jsonFeature.setDescription(sf.getDescription());
360 jsonFeature.setLinks(sf.links);
361 jsonFeature.setOtherDetails(sf.otherDetails);
362 jsonFeature.setScore(sf.getScore());
363 jsonFeature.setFillColor(featureColour);
364 jsonFeature.setFeatureGroup(sf.getFeatureGroup());
365 sequenceFeaturesPojo.add(jsonFeature);
368 return sequenceFeaturesPojo;
371 public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
372 Vector<AlignmentAnnotation> annotations)
374 List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<AlignmentAnnotationPojo>();
375 if (annotations == null)
377 return jsonAnnotations;
379 for (AlignmentAnnotation annot : annotations)
381 AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
382 alignAnnotPojo.setDescription(annot.description);
383 alignAnnotPojo.setLabel(annot.label);
384 if (!Double.isNaN(annot.score))
386 alignAnnotPojo.setScore(annot.score);
388 alignAnnotPojo.setCalcId(annot.getCalcId());
389 alignAnnotPojo.setGraphType(annot.graph);
391 AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo();
392 annotSetting.setBelowAlignment(annot.belowAlignment);
393 annotSetting.setCentreColLabels(annot.centreColLabels);
394 annotSetting.setScaleColLabel(annot.scaleColLabel);
395 annotSetting.setShowAllColLabels(annot.showAllColLabels);
396 annotSetting.setVisible(annot.visible);
397 annotSetting.setHasIcon(annot.hasIcons);
398 alignAnnotPojo.setAnnotationSettings(annotSetting);
399 SequenceI refSeq = annot.sequenceRef;
402 alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode()));
404 for (Annotation annotation : annot.annotations)
406 AnnotationPojo annotationPojo = new AnnotationPojo();
407 if (annotation != null)
409 annotationPojo.setDescription(annotation.description);
410 annotationPojo.setValue(annotation.value);
412 .setSecondaryStructure(annotation.secondaryStructure);
413 String displayChar = annotation.displayCharacter == null ? null
414 : annotation.displayCharacter;
415 // System.out.println("--------------------->[" + displayChar + "]");
416 annotationPojo.setDisplayCharacter(displayChar);
417 if (annotation.colour != null)
419 annotationPojo.setColour(jalview.util.Format
420 .getHexString(annotation.colour));
422 alignAnnotPojo.getAnnotations().add(annotationPojo);
426 if (annot.getCalcId() != null
427 && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE))
433 alignAnnotPojo.getAnnotations().add(annotationPojo);
437 jsonAnnotations.add(alignAnnotPojo);
439 return jsonAnnotations;
442 @SuppressWarnings("unchecked")
443 public JSONFile parse(Reader jsonAlignmentString)
447 JSONParser jsonParser = new JSONParser();
448 JSONObject alignmentJsonObj = (JSONObject) jsonParser
449 .parse(jsonAlignmentString);
450 JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
451 JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
452 .get("alignAnnotation");
453 JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
455 JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
457 JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
460 if (jvSettingsJsonObj != null)
462 globalColourScheme = (String) jvSettingsJsonObj
463 .get("globalColorScheme");
464 Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
465 "showSeqFeatures").toString());
466 setShowSeqFeatures(showFeatures);
467 parseHiddenSeqRefsAsList(jvSettingsJsonObj);
468 parseHiddenCols(jvSettingsJsonObj);
471 hiddenSequences = new ArrayList<SequenceI>();
472 seqMap = new Hashtable<String, Sequence>();
473 for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
476 JSONObject sequence = sequenceIter.next();
477 String sequcenceString = sequence.get("seq").toString();
478 String sequenceName = sequence.get("name").toString();
479 String seqUniqueId = sequence.get("id").toString();
480 int start = Integer.valueOf(sequence.get("start").toString());
481 int end = Integer.valueOf(sequence.get("end").toString());
482 Sequence seq = new Sequence(sequenceName, sequcenceString, start,
484 if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
486 hiddenSequences.add(seq);
489 seqMap.put(seqUniqueId, seq);
492 parseFeatures(jsonSeqArray);
494 for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
497 JSONObject seqGrpObj = seqGrpIter.next();
498 String grpName = seqGrpObj.get("groupName").toString();
499 String colourScheme = seqGrpObj.get("colourScheme").toString();
500 String description = (seqGrpObj.get("description") == null) ? null
501 : seqGrpObj.get("description").toString();
502 boolean displayBoxes = Boolean.valueOf(seqGrpObj
503 .get("displayBoxes").toString());
504 boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
506 boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
508 boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
509 "showNonconserved").toString());
510 int startRes = Integer
511 .valueOf(seqGrpObj.get("startRes").toString());
512 int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
513 JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
515 ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
516 if (sequenceRefs.size() > 0)
518 Iterator<String> seqHashIter = sequenceRefs.iterator();
519 while (seqHashIter.hasNext())
521 String seqHash = seqHashIter.next();
522 Sequence sequence = seqMap.get(seqHash);
523 if (sequence != null)
525 grpSeqs.add(sequence);
529 SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
530 displayBoxes, displayText, colourText, startRes, endRes);
531 seqGrp.setColourScheme(ColourSchemeMapper.getJalviewColourScheme(
532 colourScheme, seqGrp));
533 seqGrp.setShowNonconserved(showNonconserved);
534 seqGrp.setDescription(description);
535 this.seqGroups.add(seqGrp);
539 for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
542 JSONObject alAnnot = alAnnotIter.next();
543 JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
544 Annotation[] annotations = new Annotation[annotJsonArray.size()];
546 for (Iterator<JSONObject> annotIter = annotJsonArray.iterator(); annotIter
549 JSONObject annot = annotIter.next();
552 annotations[count] = null;
556 float val = annot.get("value") == null ? null : Float
557 .valueOf(annot.get("value").toString());
558 String desc = annot.get("description") == null ? null : annot
559 .get("description").toString();
560 char ss = annot.get("secondaryStructure") == null
561 || annot.get("secondaryStructure").toString()
562 .equalsIgnoreCase("u0000") ? ' ' : annot
563 .get("secondaryStructure").toString().charAt(0);
564 String displayChar = annot.get("displayCharacter") == null ? ""
565 : annot.get("displayCharacter").toString();
567 annotations[count] = new Annotation(displayChar, desc, ss, val);
568 if (annot.get("colour") != null)
570 Color color = ColorUtils.parseColourString(annot.get(
571 "colour").toString());
572 annotations[count].colour = color;
578 AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot
579 .get("label").toString(), alAnnot.get("description")
580 .toString(), annotations);
581 alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0 : Integer
582 .valueOf(alAnnot.get("graphType").toString());
584 JSONObject diplaySettings = (JSONObject) alAnnot
585 .get("annotationSettings");
586 if (diplaySettings != null)
589 alignAnnot.scaleColLabel = (diplaySettings.get("scaleColLabel") == null) ? false
590 : Boolean.valueOf(diplaySettings.get("scaleColLabel")
592 alignAnnot.showAllColLabels = (diplaySettings
593 .get("showAllColLabels") == null) ? true : Boolean
594 .valueOf(diplaySettings.get("showAllColLabels")
596 alignAnnot.centreColLabels = (diplaySettings
597 .get("centreColLabels") == null) ? true
598 : Boolean.valueOf(diplaySettings.get("centreColLabels")
600 alignAnnot.belowAlignment = (diplaySettings.get("belowAlignment") == null) ? false
601 : Boolean.valueOf(diplaySettings.get("belowAlignment")
603 alignAnnot.visible = (diplaySettings.get("visible") == null) ? true
604 : Boolean.valueOf(diplaySettings.get("visible")
606 alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null) ? true
607 : Boolean.valueOf(diplaySettings.get("hasIcon")
611 if (alAnnot.get("score") != null)
613 alignAnnot.score = Double
614 .valueOf(alAnnot.get("score").toString());
617 String calcId = (alAnnot.get("calcId") == null) ? "" : alAnnot.get(
618 "calcId").toString();
619 alignAnnot.setCalcId(calcId);
620 String seqHash = (alAnnot.get("sequenceRef") != null) ? alAnnot
621 .get("sequenceRef").toString() : null;
623 Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
624 if (sequence != null)
626 alignAnnot.sequenceRef = sequence;
627 sequence.addAlignmentAnnotation(alignAnnot);
628 if (alignAnnot.label.equalsIgnoreCase("T-COFFEE"))
630 alignAnnot.createSequenceMapping(sequence, sequence.getStart(),
632 sequence.addAlignmentAnnotation(alignAnnot);
633 alignAnnot.adjustForAlignment();
636 alignAnnot.validateRangeAndDisplay();
637 this.annotations.add(alignAnnot);
640 } catch (Exception e)
647 public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
649 hiddenSeqRefs = new ArrayList<String>();
650 String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
651 if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
653 String[] seqRefs = hiddenSeqs.split(";");
654 for (String seqRef : seqRefs)
656 hiddenSeqRefs.add(seqRef);
661 public void parseHiddenCols(JSONObject jvSettingsJson)
663 String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
664 if (hiddenCols != null && !hiddenCols.isEmpty())
666 hiddenColumns = new HiddenColumns();
667 String[] rangeStrings = hiddenCols.split(";");
668 for (String rangeString : rangeStrings)
670 String[] range = rangeString.split("-");
671 hiddenColumns.hideColumns(Integer.valueOf(range[0]),
672 Integer.valueOf(range[1]));
677 @SuppressWarnings("unchecked")
678 private void parseFeatures(JSONArray jsonSeqFeatures)
680 if (jsonSeqFeatures != null)
682 displayedFeatures = new FeaturesDisplayed();
683 for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
686 JSONObject jsonFeature = seqFeatureItr.next();
687 Long begin = (Long) jsonFeature.get("xStart");
688 Long end = (Long) jsonFeature.get("xEnd");
689 String type = (String) jsonFeature.get("type");
690 String featureGrp = (String) jsonFeature.get("featureGroup");
691 String description = (String) jsonFeature.get("description");
692 String seqRef = (String) jsonFeature.get("sequenceRef");
693 Float score = Float.valueOf(jsonFeature.get("score").toString());
695 Sequence seq = seqMap.get(seqRef);
698 * begin/end of 0 is for a non-positional feature
700 int featureBegin = begin.intValue() == 0 ? 0 : seq
701 .findPosition(begin.intValue());
702 int featureEnd = end.intValue() == 0 ? 0 : seq.findPosition(end
705 SequenceFeature sequenceFeature = new SequenceFeature(type,
706 description, featureBegin, featureEnd, score, featureGrp);
708 JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
709 if (linksJsonArray != null && linksJsonArray.size() > 0)
711 Iterator<String> linkList = linksJsonArray.iterator();
712 while (linkList.hasNext())
714 String link = linkList.next();
715 sequenceFeature.addLink(link);
719 seq.addSequenceFeature(sequenceFeature);
720 displayedFeatures.setVisible(type);
726 public String getGlobalColourScheme()
728 return globalColourScheme;
731 public void setGlobalColorScheme(String globalColourScheme)
733 this.globalColourScheme = globalColourScheme;
737 public FeaturesDisplayedI getDisplayedFeatures()
739 return displayedFeatures;
742 public void setDisplayedFeatures(FeaturesDisplayedI displayedFeatures)
744 this.displayedFeatures = displayedFeatures;
748 public void configureForView(AlignmentViewPanel avpanel)
754 super.configureForView(avpanel);
755 AlignViewportI viewport = avpanel.getAlignViewport();
756 AlignmentI alignment = viewport.getAlignment();
757 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
759 seqGroups = alignment.getGroups();
760 fr = avpanel.cloneFeatureRenderer();
762 // Add non auto calculated annotation to AlignFile
765 for (AlignmentAnnotation annot : annots)
767 if (annot != null && !annot.autoCalculated)
769 annotations.add(annot);
773 globalColourScheme = ColourSchemeProperty.getColourName(viewport
774 .getGlobalColourScheme());
775 setDisplayedFeatures(viewport.getFeaturesDisplayed());
776 showSeqFeatures = viewport.isShowSequenceFeatures();
781 public boolean isShowSeqFeatures()
783 return showSeqFeatures;
786 public void setShowSeqFeatures(boolean showSeqFeatures)
788 this.showSeqFeatures = showSeqFeatures;
791 public Vector<AlignmentAnnotation> getAnnotations()
797 public HiddenColumns getHiddenColumns()
799 return hiddenColumns;
802 public void setHiddenColumns(HiddenColumns hidden)
804 this.hiddenColumns = hidden;
808 public SequenceI[] getHiddenSequences()
810 if (hiddenSequences == null || hiddenSequences.isEmpty())
812 return new SequenceI[] {};
814 synchronized (hiddenSequences)
816 return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
820 public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
822 this.hiddenSequences = hiddenSequences;
825 public class JSONExportSettings
827 private boolean exportSequence;
829 private boolean exportSequenceFeatures;
831 private boolean exportAnnotations;
833 private boolean exportGroups;
835 private boolean exportJalviewSettings;
837 public boolean isExportSequence()
839 return exportSequence;
842 public void setExportSequence(boolean exportSequence)
844 this.exportSequence = exportSequence;
847 public boolean isExportSequenceFeatures()
849 return exportSequenceFeatures;
852 public void setExportSequenceFeatures(boolean exportSequenceFeatures)
854 this.exportSequenceFeatures = exportSequenceFeatures;
857 public boolean isExportAnnotations()
859 return exportAnnotations;
862 public void setExportAnnotations(boolean exportAnnotations)
864 this.exportAnnotations = exportAnnotations;
867 public boolean isExportGroups()
872 public void setExportGroups(boolean exportGroups)
874 this.exportGroups = exportGroups;
877 public boolean isExportJalviewSettings()
879 return exportJalviewSettings;
882 public void setExportJalviewSettings(boolean exportJalviewSettings)
884 this.exportJalviewSettings = exportJalviewSettings;
889 * Returns a descriptor for suitable feature display settings with
891 * <li>ResNums or insertions features visible</li>
892 * <li>insertions features coloured red</li>
893 * <li>ResNum features coloured by label</li>
894 * <li>Insertions displayed above (on top of) ResNums</li>
898 public FeatureSettingsModelI getFeatureColourScheme()
900 return new PDBFeatureSettings();