-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bioSyntax color schemes as sequence alignment renderers
- Loading branch information
1 parent
7b525ec
commit fb35fed
Showing
10 changed files
with
365 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-26.9 KB
gc4s-multiple-sequence-alignment-viewer/screenshots/GenomeBrowser.png
Binary file not shown.
Binary file modified
BIN
-2.78 KB
(95%)
...-sequence-alignment-viewer/screenshots/MultipleSequenceAlignmentViewerPanel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52.7 KB
...alignment-viewer/screenshots/MultipleSequenceAlignmentViewerPanel_bioSyntax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions
48
...equence-alignment-viewer/src/main/java/org/sing_group/gc4s/msaviewer/BaseColorScheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* #%L | ||
* GC4S multiple sequence alignment viewer | ||
* %% | ||
* Copyright (C) 2014 - 2018 Hugo López-Fernández, Daniel Glez-Peña, Miguel Reboiro-Jato, | ||
* Florentino Fdez-Riverola, Rosalía Laza-Fidalgo, Reyes Pavón-Rial | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.sing_group.gc4s.msaviewer; | ||
|
||
import java.awt.Color; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* The interface that defines a color scheme used by a {@code BaseColorSequenceAlignmentRenderer}. | ||
* | ||
* @author hlfernandez | ||
* | ||
*/ | ||
public interface BaseColorScheme { | ||
/** | ||
* Returns a function that returns a background {@code Color} for each sequence base {@code Character}. | ||
* | ||
* @return a function that returns a background {@code Color} for each sequence base {@code Character} | ||
*/ | ||
Function<Character, Color> getBaseBackgroundColorFunction(); | ||
|
||
/** | ||
* Returns a function that returns a foreground {@code Color} for each sequence base {@code Character}. | ||
* | ||
* @return a function that returns a foreground {@code Color} for each sequence base {@code Character} | ||
*/ | ||
Function<Character, Color> getBaseForegroundColorFunction(); | ||
} |
63 changes: 63 additions & 0 deletions
63
...iewer/src/main/java/org/sing_group/gc4s/msaviewer/BaseColorSequenceAlignmentRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* #%L | ||
* GC4S multiple sequence alignment viewer | ||
* %% | ||
* Copyright (C) 2014 - 2018 Hugo López-Fernández, Daniel Glez-Peña, Miguel Reboiro-Jato, | ||
* Florentino Fdez-Riverola, Rosalía Laza-Fidalgo, Reyes Pavón-Rial | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.sing_group.gc4s.msaviewer; | ||
|
||
import static java.util.Optional.of; | ||
|
||
import java.awt.Color; | ||
import java.util.Optional; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* A {@code DefaultSequenceAlignmentRenderer} implementation that renders each | ||
* sequence base using the color specified by the {@code BaseColorScheme}. | ||
* | ||
* @author hlfernandez | ||
* @see BaseColorScheme | ||
* @see DefaultSequenceAlignmentRenderer | ||
* | ||
*/ | ||
public class BaseColorSequenceAlignmentRenderer extends DefaultSequenceAlignmentRenderer { | ||
private Function<Character, Color> backgroundColorProvider; | ||
private Function<Character, Color> foregroundColorProvider; | ||
|
||
/** | ||
* Creates a new {@code BaseColorSequenceAlignmentRenderer} with the specified {@code colorScheme}. | ||
* | ||
* @param colorScheme the {@code BaseColorScheme} to render sequence bases | ||
*/ | ||
public BaseColorSequenceAlignmentRenderer( | ||
BaseColorScheme colorScheme | ||
) { | ||
this.backgroundColorProvider = colorScheme.getBaseBackgroundColorFunction(); | ||
this.foregroundColorProvider = colorScheme.getBaseForegroundColorFunction(); | ||
} | ||
|
||
@Override | ||
public Optional<SequenceBaseRenderingInfo> render(Sequence sequence, int position) { | ||
Character base = sequence.getSequence().charAt(position); | ||
return of( | ||
new SequenceBaseRenderingInfo(this.backgroundColorProvider.apply(base), this.foregroundColorProvider.apply(base), false, false) | ||
); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...lignment-viewer/src/main/java/org/sing_group/gc4s/msaviewer/BioSyntaxBaseColorScheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* #%L | ||
* GC4S multiple sequence alignment viewer | ||
* %% | ||
* Copyright (C) 2014 - 2018 Hugo López-Fernández, Daniel Glez-Peña, Miguel Reboiro-Jato, | ||
* Florentino Fdez-Riverola, Rosalía Laza-Fidalgo, Reyes Pavón-Rial | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.sing_group.gc4s.msaviewer; | ||
|
||
import static java.awt.Color.decode; | ||
|
||
import java.awt.Color; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* An {@code DefaultBaseColorScheme} extension that returns the bioSyntax color scheme (https://biosyntax.org/, | ||
* https://doi.org/10.1186/s12859-018-2315-y). | ||
* | ||
* @author hlfernandez | ||
* | ||
*/ | ||
public class BioSyntaxBaseColorScheme extends DefaultBaseColorScheme { | ||
public static final Map<Character, Color> BIO_SYNTAX_COLOR_SCHEME = new HashMap<>(); | ||
|
||
static { | ||
BIO_SYNTAX_COLOR_SCHEME.put('A', decode("#47ff19")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('G', decode("#f09000")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('C', decode("#ff4641")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('T', decode("#4192ff")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME.put('U', decode("#8a89ff")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME.put('R', decode("#fffe80")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('S', decode("#ff9b80")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('Y', decode("#e180ff")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('W', decode("#80fff2")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME.put('D', decode("#c7ffb9")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('V', decode("#ffe3b9")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('B', decode("#f8c1c0")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('H', decode("#bfd8f9")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME.put('X', decode("#e6e6e6")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('N', decode("#ffffff")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('M', decode("#83831f")); | ||
BIO_SYNTAX_COLOR_SCHEME.put('K', decode("#8b4915")); | ||
} | ||
|
||
/** | ||
* Creates a new {@code BioSyntaxBaseColorScheme} instance. | ||
*/ | ||
public BioSyntaxBaseColorScheme() { | ||
super(asFunction(BIO_SYNTAX_COLOR_SCHEME), (Character c) -> Color.BLACK); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
...wer/src/main/java/org/sing_group/gc4s/msaviewer/BioSyntaxHighContrastBaseColorScheme.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* #%L | ||
* GC4S multiple sequence alignment viewer | ||
* %% | ||
* Copyright (C) 2014 - 2018 Hugo López-Fernández, Daniel Glez-Peña, Miguel Reboiro-Jato, | ||
* Florentino Fdez-Riverola, Rosalía Laza-Fidalgo, Reyes Pavón-Rial | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.sing_group.gc4s.msaviewer; | ||
|
||
import static java.awt.Color.decode; | ||
|
||
import java.awt.Color; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* An {@code DefaultBaseColorScheme} extension that returns the bioSyntax color scheme (https://biosyntax.org/, | ||
* https://doi.org/10.1186/s12859-018-2315-y). | ||
* | ||
* @author hlfernandez | ||
* | ||
*/ | ||
public class BioSyntaxHighContrastBaseColorScheme extends DefaultBaseColorScheme { | ||
public static final Map<Character, Color> BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST = new HashMap<>(); | ||
|
||
static { | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('A', decode("#d1d1d1")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('G', decode("#fe3101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('C', decode("#010101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('T', decode("#4091fe")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('U', decode("#495bfe")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('R', decode("#f399cd")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('S', decode("#7c0101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('Y', decode("#00007d")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('W', decode("#7cc7fe")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('D', decode("#edb78d")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('V', decode("#fe6331")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('B', decode("#8a4814")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('H', decode("#bed7f8")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('X', decode("#ffffff")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('N', decode("#ffffff")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('M', decode("#fefd7f")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST.put('K', decode("#9208a0")); | ||
} | ||
|
||
public static final Map<Character, Color> BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND = new HashMap<>(); | ||
|
||
static { | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('A', decode("#010101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('G', decode("#010101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('C', decode("#fefefe")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('T', decode("#fefefe")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('U', decode("#fefefe")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('R', decode("#010101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('S', decode("#fefefe")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('Y', decode("#fefefe")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('W', decode("#010101")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('D', decode("#fefefe")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('V', decode("#fefefe")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('B', decode("#fefefe")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('H', decode("#010101")); | ||
|
||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('X', decode("#828282")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('N', decode("#828282")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('M', decode("#010101")); | ||
BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND.put('K', decode("#010101")); | ||
} | ||
|
||
public BioSyntaxHighContrastBaseColorScheme() { | ||
super( | ||
asFunction(BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST), asFunction(BIO_SYNTAX_COLOR_SCHEME_HIGH_CONTRAST_FOREGROUND) | ||
); | ||
} | ||
} |
Oops, something went wrong.