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.ColumnSelection;
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.JalviewColourScheme;
51 import jalview.schemes.ResidueColourScheme;
52 import jalview.util.ColorUtils;
53 import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
55 import java.awt.Color;
56 import java.io.IOException;
57 import java.io.Reader;
58 import java.util.ArrayList;
59 import java.util.Hashtable;
60 import java.util.Iterator;
61 import java.util.List;
62 import java.util.Vector;
64 import org.json.simple.JSONArray;
65 import org.json.simple.JSONObject;
66 import org.json.simple.parser.JSONParser;
68 public class JSONFile extends AlignFile implements ComplexAlignFile
70 private static String version = new BuildDetails().getVersion();
72 private String webstartUrl = "http://www.jalview.org/services/launchApp";
74 private String application = "Jalview";
76 private String globalColourScheme;
78 private boolean showSeqFeatures;
80 private Hashtable<String, Sequence> seqMap;
82 private FeaturesDisplayedI displayedFeatures;
84 private FeatureRenderer fr;
86 private List<int[]> hiddenColumns;
88 private ColumnSelection columnSelection;
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())
233 .setSeqFeatures(sequenceFeatureToJsonPojo(sqs, fr));
236 if (exportSettings.isExportGroups() && seqGroups != null
237 && seqGroups.size() > 0)
239 for (SequenceGroup seqGrp : seqGroups)
241 SequenceGrpPojo seqGrpPojo = new SequenceGrpPojo();
242 seqGrpPojo.setGroupName(seqGrp.getName());
243 seqGrpPojo.setColourScheme(seqGrp.getColourScheme()
245 seqGrpPojo.setColourText(seqGrp.getColourText());
246 seqGrpPojo.setDescription(seqGrp.getDescription());
247 seqGrpPojo.setDisplayBoxes(seqGrp.getDisplayBoxes());
248 seqGrpPojo.setDisplayText(seqGrp.getDisplayText());
249 seqGrpPojo.setEndRes(seqGrp.getEndRes());
250 seqGrpPojo.setStartRes(seqGrp.getStartRes());
251 seqGrpPojo.setShowNonconserved(seqGrp.getShowNonconserved());
252 for (SequenceI seq : seqGrp.getSequences())
254 seqGrpPojo.getSequenceRefs()
255 .add(String.valueOf(seq.hashCode()));
257 jsonAlignmentPojo.getSeqGroups().add(seqGrpPojo);
260 org.json.JSONObject generatedJSon = new org.json.JSONObject(
262 jsonOutput = generatedJSon.toString();
263 return jsonOutput.replaceAll("xstart", "xStart").replaceAll("xend",
265 } catch (Exception e)
272 public String[] getHiddenSections()
274 String[] hiddenSections = new String[2];
275 if (getViewport() == null)
280 // hidden column business
281 if (getViewport().hasHiddenColumns())
283 List<int[]> hiddenCols = getViewport().getColumnSelection()
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 public List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
323 SequenceI[] sqs, FeatureRenderer fr)
325 displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
326 List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
329 return sequenceFeaturesPojo;
332 FeatureColourFinder finder = new FeatureColourFinder(fr);
334 for (SequenceI seq : sqs)
336 SequenceI dataSetSequence = seq.getDatasetSequence();
337 SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null
338 : seq.getDatasetSequence().getSequenceFeatures();
340 seqFeatures = (seqFeatures == null) ? seq.getSequenceFeatures()
342 if (seqFeatures == null)
347 for (SequenceFeature sf : seqFeatures)
349 if (displayedFeatures != null
350 && displayedFeatures.isVisible(sf.getType()))
352 SequenceFeaturesPojo jsonFeature = new SequenceFeaturesPojo(
353 String.valueOf(seq.hashCode()));
355 String featureColour = (fr == null) ? null : jalview.util.Format
356 .getHexString(finder.findFeatureColour(Color.white, seq,
357 seq.findIndex(sf.getBegin())));
358 jsonFeature.setXstart(seq.findIndex(sf.getBegin()) - 1);
359 jsonFeature.setXend(seq.findIndex(sf.getEnd()));
360 jsonFeature.setType(sf.getType());
361 jsonFeature.setDescription(sf.getDescription());
362 jsonFeature.setLinks(sf.links);
363 jsonFeature.setOtherDetails(sf.otherDetails);
364 jsonFeature.setScore(sf.getScore());
365 jsonFeature.setFillColor(featureColour);
366 jsonFeature.setFeatureGroup(sf.getFeatureGroup());
367 sequenceFeaturesPojo.add(jsonFeature);
371 return sequenceFeaturesPojo;
374 public static List<AlignmentAnnotationPojo> annotationToJsonPojo(
375 Vector<AlignmentAnnotation> annotations)
377 List<AlignmentAnnotationPojo> jsonAnnotations = new ArrayList<AlignmentAnnotationPojo>();
378 if (annotations == null)
380 return jsonAnnotations;
382 for (AlignmentAnnotation annot : annotations)
384 AlignmentAnnotationPojo alignAnnotPojo = new AlignmentAnnotationPojo();
385 alignAnnotPojo.setDescription(annot.description);
386 alignAnnotPojo.setLabel(annot.label);
387 if (!Double.isNaN(annot.score))
389 alignAnnotPojo.setScore(annot.score);
391 alignAnnotPojo.setCalcId(annot.getCalcId());
392 alignAnnotPojo.setGraphType(annot.graph);
394 AnnotationDisplaySettingPojo annotSetting = new AnnotationDisplaySettingPojo();
395 annotSetting.setBelowAlignment(annot.belowAlignment);
396 annotSetting.setCentreColLabels(annot.centreColLabels);
397 annotSetting.setScaleColLabel(annot.scaleColLabel);
398 annotSetting.setShowAllColLabels(annot.showAllColLabels);
399 annotSetting.setVisible(annot.visible);
400 annotSetting.setHasIcon(annot.hasIcons);
401 alignAnnotPojo.setAnnotationSettings(annotSetting);
402 SequenceI refSeq = annot.sequenceRef;
405 alignAnnotPojo.setSequenceRef(String.valueOf(refSeq.hashCode()));
407 for (Annotation annotation : annot.annotations)
409 AnnotationPojo annotationPojo = new AnnotationPojo();
410 if (annotation != null)
412 annotationPojo.setDescription(annotation.description);
413 annotationPojo.setValue(annotation.value);
415 .setSecondaryStructure(annotation.secondaryStructure);
416 String displayChar = annotation.displayCharacter == null ? null
417 : annotation.displayCharacter;
418 // System.out.println("--------------------->[" + displayChar + "]");
419 annotationPojo.setDisplayCharacter(displayChar);
420 if (annotation.colour != null)
422 annotationPojo.setColour(jalview.util.Format
423 .getHexString(annotation.colour));
425 alignAnnotPojo.getAnnotations().add(annotationPojo);
429 if (annot.getCalcId() != null
430 && annot.getCalcId().equalsIgnoreCase(TCOFFEE_SCORE))
436 alignAnnotPojo.getAnnotations().add(annotationPojo);
440 jsonAnnotations.add(alignAnnotPojo);
442 return jsonAnnotations;
445 @SuppressWarnings("unchecked")
446 public JSONFile parse(Reader jsonAlignmentString)
450 JSONParser jsonParser = new JSONParser();
451 JSONObject alignmentJsonObj = (JSONObject) jsonParser
452 .parse(jsonAlignmentString);
453 JSONArray seqJsonArray = (JSONArray) alignmentJsonObj.get("seqs");
454 JSONArray alAnnotJsonArray = (JSONArray) alignmentJsonObj
455 .get("alignAnnotation");
456 JSONArray jsonSeqArray = (JSONArray) alignmentJsonObj
458 JSONArray seqGrpJsonArray = (JSONArray) alignmentJsonObj
460 JSONObject jvSettingsJsonObj = (JSONObject) alignmentJsonObj
463 if (jvSettingsJsonObj != null)
465 globalColourScheme = (String) jvSettingsJsonObj
466 .get("globalColorScheme");
467 Boolean showFeatures = Boolean.valueOf(jvSettingsJsonObj.get(
468 "showSeqFeatures").toString());
469 setShowSeqFeatures(showFeatures);
470 parseHiddenSeqRefsAsList(jvSettingsJsonObj);
471 parseHiddenCols(jvSettingsJsonObj);
474 hiddenSequences = new ArrayList<SequenceI>();
475 seqMap = new Hashtable<String, Sequence>();
476 for (Iterator<JSONObject> sequenceIter = seqJsonArray.iterator(); sequenceIter
479 JSONObject sequence = sequenceIter.next();
480 String sequcenceString = sequence.get("seq").toString();
481 String sequenceName = sequence.get("name").toString();
482 String seqUniqueId = sequence.get("id").toString();
483 int start = Integer.valueOf(sequence.get("start").toString());
484 int end = Integer.valueOf(sequence.get("end").toString());
485 Sequence seq = new Sequence(sequenceName, sequcenceString, start,
487 if (hiddenSeqRefs != null && hiddenSeqRefs.contains(seqUniqueId))
489 hiddenSequences.add(seq);
492 seqMap.put(seqUniqueId, seq);
495 parseFeatures(jsonSeqArray);
497 for (Iterator<JSONObject> seqGrpIter = seqGrpJsonArray.iterator(); seqGrpIter
500 JSONObject seqGrpObj = seqGrpIter.next();
501 String grpName = seqGrpObj.get("groupName").toString();
502 String colourScheme = seqGrpObj.get("colourScheme").toString();
503 String description = (seqGrpObj.get("description") == null) ? null
504 : seqGrpObj.get("description").toString();
505 boolean displayBoxes = Boolean.valueOf(seqGrpObj
506 .get("displayBoxes").toString());
507 boolean displayText = Boolean.valueOf(seqGrpObj.get("displayText")
509 boolean colourText = Boolean.valueOf(seqGrpObj.get("colourText")
511 boolean showNonconserved = Boolean.valueOf(seqGrpObj.get(
512 "showNonconserved").toString());
513 int startRes = Integer
514 .valueOf(seqGrpObj.get("startRes").toString());
515 int endRes = Integer.valueOf(seqGrpObj.get("endRes").toString());
516 JSONArray sequenceRefs = (JSONArray) seqGrpObj.get("sequenceRefs");
518 ArrayList<SequenceI> grpSeqs = new ArrayList<SequenceI>();
519 if (sequenceRefs.size() > 0)
521 Iterator<String> seqHashIter = sequenceRefs.iterator();
522 while (seqHashIter.hasNext())
524 String seqHash = seqHashIter.next();
525 Sequence sequence = seqMap.get(seqHash);
526 if (sequence != null)
528 grpSeqs.add(sequence);
532 SequenceGroup seqGrp = new SequenceGroup(grpSeqs, grpName, null,
533 displayBoxes, displayText, colourText, startRes, endRes);
534 seqGrp.setColourScheme(ColourSchemeMapper.getJalviewColourScheme(
535 colourScheme, seqGrp));
536 seqGrp.setShowNonconserved(showNonconserved);
537 seqGrp.setDescription(description);
538 this.seqGroups.add(seqGrp);
542 for (Iterator<JSONObject> alAnnotIter = alAnnotJsonArray.iterator(); alAnnotIter
545 JSONObject alAnnot = alAnnotIter.next();
546 JSONArray annotJsonArray = (JSONArray) alAnnot.get("annotations");
547 Annotation[] annotations = new Annotation[annotJsonArray.size()];
549 for (Iterator<JSONObject> annotIter = annotJsonArray.iterator(); annotIter
552 JSONObject annot = annotIter.next();
555 annotations[count] = null;
559 float val = annot.get("value") == null ? null : Float
560 .valueOf(annot.get("value").toString());
561 String desc = annot.get("description") == null ? null : annot
562 .get("description").toString();
563 char ss = annot.get("secondaryStructure") == null
564 || annot.get("secondaryStructure").toString()
565 .equalsIgnoreCase("u0000") ? ' ' : annot
566 .get("secondaryStructure").toString().charAt(0);
567 String displayChar = annot.get("displayCharacter") == null ? ""
568 : annot.get("displayCharacter").toString();
570 annotations[count] = new Annotation(displayChar, desc, ss, val);
571 if (annot.get("colour") != null)
573 Color color = ColorUtils.parseColourString(annot.get(
574 "colour").toString());
575 annotations[count].colour = color;
581 AlignmentAnnotation alignAnnot = new AlignmentAnnotation(alAnnot
582 .get("label").toString(), alAnnot.get("description")
583 .toString(), annotations);
584 alignAnnot.graph = (alAnnot.get("graphType") == null) ? 0 : Integer
585 .valueOf(alAnnot.get("graphType").toString());
587 JSONObject diplaySettings = (JSONObject) alAnnot
588 .get("annotationSettings");
589 if (diplaySettings != null)
592 alignAnnot.scaleColLabel = (diplaySettings.get("scaleColLabel") == null) ? false
593 : Boolean.valueOf(diplaySettings.get("scaleColLabel")
595 alignAnnot.showAllColLabels = (diplaySettings
596 .get("showAllColLabels") == null) ? true : Boolean
597 .valueOf(diplaySettings.get("showAllColLabels")
599 alignAnnot.centreColLabels = (diplaySettings
600 .get("centreColLabels") == null) ? true
601 : Boolean.valueOf(diplaySettings.get("centreColLabels")
603 alignAnnot.belowAlignment = (diplaySettings.get("belowAlignment") == null) ? false
604 : Boolean.valueOf(diplaySettings.get("belowAlignment")
606 alignAnnot.visible = (diplaySettings.get("visible") == null) ? true
607 : Boolean.valueOf(diplaySettings.get("visible")
609 alignAnnot.hasIcons = (diplaySettings.get("hasIcon") == null) ? true
610 : Boolean.valueOf(diplaySettings.get("hasIcon")
614 if (alAnnot.get("score") != null)
616 alignAnnot.score = Double
617 .valueOf(alAnnot.get("score").toString());
620 String calcId = (alAnnot.get("calcId") == null) ? "" : alAnnot.get(
621 "calcId").toString();
622 alignAnnot.setCalcId(calcId);
623 String seqHash = (alAnnot.get("sequenceRef") != null) ? alAnnot
624 .get("sequenceRef").toString() : null;
626 Sequence sequence = (seqHash != null) ? seqMap.get(seqHash) : null;
627 if (sequence != null)
629 alignAnnot.sequenceRef = sequence;
630 sequence.addAlignmentAnnotation(alignAnnot);
631 if (alignAnnot.label.equalsIgnoreCase("T-COFFEE"))
633 alignAnnot.createSequenceMapping(sequence, sequence.getStart(),
635 sequence.addAlignmentAnnotation(alignAnnot);
636 alignAnnot.adjustForAlignment();
639 alignAnnot.validateRangeAndDisplay();
640 this.annotations.add(alignAnnot);
643 } catch (Exception e)
650 public void parseHiddenSeqRefsAsList(JSONObject jvSettingsJson)
652 hiddenSeqRefs = new ArrayList<String>();
653 String hiddenSeqs = (String) jvSettingsJson.get("hiddenSeqs");
654 if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
656 String[] seqRefs = hiddenSeqs.split(";");
657 for (String seqRef : seqRefs)
659 hiddenSeqRefs.add(seqRef);
664 public void parseHiddenCols(JSONObject jvSettingsJson)
666 String hiddenCols = (String) jvSettingsJson.get("hiddenCols");
667 if (hiddenCols != null && !hiddenCols.isEmpty())
669 columnSelection = new ColumnSelection();
670 String[] rangeStrings = hiddenCols.split(";");
671 for (String rangeString : rangeStrings)
673 String[] range = rangeString.split("-");
674 columnSelection.hideColumns(Integer.valueOf(range[0]),
675 Integer.valueOf(range[1]));
680 @SuppressWarnings("unchecked")
681 private void parseFeatures(JSONArray jsonSeqFeatures)
683 if (jsonSeqFeatures != null)
685 displayedFeatures = new FeaturesDisplayed();
686 for (Iterator<JSONObject> seqFeatureItr = jsonSeqFeatures.iterator(); seqFeatureItr
689 JSONObject jsonFeature = seqFeatureItr.next();
690 Long begin = (Long) jsonFeature.get("xStart");
691 Long end = (Long) jsonFeature.get("xEnd");
692 String type = (String) jsonFeature.get("type");
693 String featureGrp = (String) jsonFeature.get("featureGroup");
694 String descripiton = (String) jsonFeature.get("description");
695 String seqRef = (String) jsonFeature.get("sequenceRef");
696 Float score = Float.valueOf(jsonFeature.get("score").toString());
698 Sequence seq = seqMap.get(seqRef);
699 SequenceFeature sequenceFeature = new SequenceFeature();
700 JSONArray linksJsonArray = (JSONArray) jsonFeature.get("links");
701 if (linksJsonArray != null && linksJsonArray.size() > 0)
703 Iterator<String> linkList = linksJsonArray.iterator();
704 while (linkList.hasNext())
706 String link = linkList.next();
707 sequenceFeature.addLink(link);
710 sequenceFeature.setFeatureGroup(featureGrp);
711 sequenceFeature.setScore(score);
712 sequenceFeature.setDescription(descripiton);
713 sequenceFeature.setType(type);
714 sequenceFeature.setBegin(seq.findPosition(begin.intValue()));
715 sequenceFeature.setEnd(seq.findPosition(end.intValue()) - 1);
716 seq.addSequenceFeature(sequenceFeature);
717 displayedFeatures.setVisible(type);
723 public String getGlobalColourScheme()
725 return globalColourScheme;
728 public void setGlobalColorScheme(String globalColourScheme)
730 this.globalColourScheme = globalColourScheme;
734 public FeaturesDisplayedI getDisplayedFeatures()
736 return displayedFeatures;
739 public void setDisplayedFeatures(FeaturesDisplayedI displayedFeatures)
741 this.displayedFeatures = displayedFeatures;
745 public void configureForView(AlignmentViewPanel avpanel)
751 super.configureForView(avpanel);
752 AlignViewportI viewport = avpanel.getAlignViewport();
753 AlignmentI alignment = viewport.getAlignment();
754 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
756 seqGroups = alignment.getGroups();
757 fr = avpanel.cloneFeatureRenderer();
759 // Add non auto calculated annotation to AlignFile
762 for (AlignmentAnnotation annot : annots)
764 if (annot != null && !annot.autoCalculated)
766 annotations.add(annot);
770 globalColourScheme = viewport.getGlobalColourScheme().getSchemeName();
771 setDisplayedFeatures(viewport.getFeaturesDisplayed());
772 showSeqFeatures = viewport.isShowSequenceFeatures();
777 public boolean isShowSeqFeatures()
779 return showSeqFeatures;
782 public void setShowSeqFeatures(boolean showSeqFeatures)
784 this.showSeqFeatures = showSeqFeatures;
787 public Vector<AlignmentAnnotation> getAnnotations()
792 public List<int[]> getHiddenColumns()
794 return hiddenColumns;
798 public ColumnSelection getColumnSelection()
800 return columnSelection;
803 public void setColumnSelection(ColumnSelection columnSelection)
805 this.columnSelection = columnSelection;
809 public SequenceI[] getHiddenSequences()
811 if (hiddenSequences == null || hiddenSequences.isEmpty())
813 return new SequenceI[] {};
815 synchronized (hiddenSequences)
817 return hiddenSequences.toArray(new SequenceI[hiddenSequences.size()]);
821 public void setHiddenSequences(ArrayList<SequenceI> hiddenSequences)
823 this.hiddenSequences = hiddenSequences;
826 public class JSONExportSettings
828 private boolean exportSequence;
830 private boolean exportSequenceFeatures;
832 private boolean exportAnnotations;
834 private boolean exportGroups;
836 private boolean exportJalviewSettings;
838 public boolean isExportSequence()
840 return exportSequence;
843 public void setExportSequence(boolean exportSequence)
845 this.exportSequence = exportSequence;
848 public boolean isExportSequenceFeatures()
850 return exportSequenceFeatures;
853 public void setExportSequenceFeatures(boolean exportSequenceFeatures)
855 this.exportSequenceFeatures = exportSequenceFeatures;
858 public boolean isExportAnnotations()
860 return exportAnnotations;
863 public void setExportAnnotations(boolean exportAnnotations)
865 this.exportAnnotations = exportAnnotations;
868 public boolean isExportGroups()
873 public void setExportGroups(boolean exportGroups)
875 this.exportGroups = exportGroups;
878 public boolean isExportJalviewSettings()
880 return exportJalviewSettings;
883 public void setExportJalviewSettings(boolean exportJalviewSettings)
885 this.exportJalviewSettings = exportJalviewSettings;
890 * Returns a descriptor for suitable feature display settings with
892 * <li>ResNums or insertions features visible</li>
893 * <li>insertions features coloured red</li>
894 * <li>ResNum features coloured by label</li>
895 * <li>Insertions displayed above (on top of) ResNums</li>
899 public FeatureSettingsModelI getFeatureColourScheme()
901 return new PDBFeatureSettings();