Skip to content

Commit

Permalink
Support for variant review image and meta data generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Dec 5, 2017
1 parent 51ee809 commit 6d4eaf3
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 96 deletions.
55 changes: 28 additions & 27 deletions src/org/broad/igv/ga4gh/OAuthUtils.java
Expand Up @@ -71,7 +71,7 @@ public class OAuthUtils {
private static final String PROPERTIES_URL = "https://igvdata.broadinstitute.org/app/oauth_native.json";
private String genomicsScope = "https://www.googleapis.com/auth/genomics";
private String gsScope = "https://www.googleapis.com/auth/devstorage.read_write";
private String profileScope = "https://www.googleapis.com/auth/userinfo.profile";
private String emailScope = "https://www.googleapis.com/auth/userinfo.email";
private String state = "%2Fprofile";
private String redirectURI = "http%3A%2F%2Flocalhost%3A60151%2FoauthCallback";
private String oobURI = "urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob";
Expand All @@ -89,19 +89,23 @@ public class OAuthUtils {

private static OAuthUtils theInstance;
private String currentUserName;
private String currentUserEmail;
private String currentUserID;


// dwm08
// by default this is the google scope
private String scope = genomicsScope + "%20" + gsScope + "%20" + profileScope;
private String scope = genomicsScope + "%20" + gsScope + "%20" + emailScope;

// Construct OAuthUtils earcly so Google menu can be updated to the
// Construct OAuthUtils earcly so Google menu can be updated to the
// correct oauth provider. dwm08
static {
if (theInstance == null) {
if (theInstance == null) {
theInstance = new OAuthUtils();
}
}


public static synchronized OAuthUtils getInstance() {

if (theInstance == null) {
Expand Down Expand Up @@ -174,7 +178,7 @@ private void fetchOauthProperties() throws IOException {
* @throws URISyntaxException
*/
public void openAuthorizationPage() throws IOException, URISyntaxException {
Desktop desktop = Desktop.getDesktop();
Desktop desktop = Desktop.getDesktop();

// properties moved to early init dwm08
//if (clientId == null) fetchOauthProperties();
Expand Down Expand Up @@ -213,13 +217,13 @@ public void openAuthorizationPage() throws IOException, URISyntaxException {
// throw new IOException("Either scope or resource must be provided to authenticate.");
// }

// check if the "browse" Desktop action is suppported (many Linux DEs cannot directly
// launch browsers!)
if(desktop.isSupported(Desktop.Action.BROWSE)) {
desktop.browse(new URI(url));
} else { // otherwise, display a dialog box for the user to copy the URL manually.
MessageUtils.showMessage("Copy this authorization URL into your web browser: " + url);
}
// check if the "browse" Desktop action is suppported (many Linux DEs cannot directly
// launch browsers!)
if (desktop.isSupported(Desktop.Action.BROWSE)) {
desktop.browse(new URI(url));
} else { // otherwise, display a dialog box for the user to copy the URL manually.
MessageUtils.showMessage("Copy this authorization URL into your web browser: " + url);
}

// if the listener is not active, prompt the user
// for the access token
Expand Down Expand Up @@ -335,29 +339,26 @@ private void reauthorize() throws IOException {
*
* @throws IOException
*/
private void fetchUserProfile() throws IOException {

// dwm08 - removing functionality to get user profile info from microsoft oauth. Just not worth the trouble
// JWT jwt = JWT.decode(accessToken);
// Map<String, Claim> claims = jwt.getClaims();
// for (String claim: claims.keySet()) {
// System.out.println(claim + " = " + claims.get(claim).asString());
// }
// currentUserName = claims.get("unique_name").asString();
public JsonObject fetchUserProfile() throws IOException {

try {
URL url = new URL("https://www.googleapis.com/plus/v1/people/me?access_token=" + accessToken);

URL url = new URL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + accessToken);
String response = HttpUtils.getInstance().getContentsAsJSON(url);
JsonParser parser = new JsonParser();
JsonObject obj = parser.parse(response).getAsJsonObject();
currentUserName = obj.get("displayName").getAsString();

} catch (Throwable exception){

}
currentUserName = obj.get("name").getAsString();
currentUserEmail = obj.get("email").getAsString();
currentUserID = obj.get("id").getAsString();

return obj;
} catch (Throwable exception) {
log.error(exception);
return null;
}
}


public String getAccessToken() {

// Check expiration time, with 1 minute cushion
Expand Down
21 changes: 1 addition & 20 deletions src/org/broad/igv/sam/AlignmentTrack.java
Expand Up @@ -132,7 +132,7 @@ public class AlignmentTrack extends AbstractTrack implements IGVEventObserver {

private int minHeight = 50;
private AlignmentDataManager dataManager;
private Rectangle alignmentsRect;
public Rectangle alignmentsRect;
private Rectangle downsampleRect;
private Rectangle insertionRect;
private ColorTable readNamePalette;
Expand Down Expand Up @@ -1501,8 +1501,6 @@ public void actionPerformed(ActionEvent e) {
addExtViewItem(e);
}

addScoreMutationItem(e);


}

Expand Down Expand Up @@ -2244,24 +2242,7 @@ private void addInsertionItems(AlignmentBlock insertion) {
}
}

public void addScoreMutationItem(final TrackClickEvent te) {
// Change track height by attribute
final JMenuItem item = new JMenuItem("Score mutation");
add(item);


item.addActionListener(aEvt -> {
CommandExecutor cmdExe = new CommandExecutor();
cmdExe.setSleepInterval("0");

int chrPosition = (int) Math.round(te.getChromosomePosition()) + 1; // Convert to "1" base coords
System.out.println(chrPosition);
cmdExe.execute("goto " + te.getFrame().getChrName() + ":" + chrPosition);
cmdExe.execute("sort base " + chrPosition);

});

}

}

Expand Down
2 changes: 1 addition & 1 deletion src/org/broad/igv/sam/BaseAlignmentCounts.java
Expand Up @@ -199,9 +199,9 @@ public String getValueStringAt(int pos) {
}

return buf.toString();

}


/**
* Return true if the mismatched (with respect to ref) read bases at the given position exceed the threshold.
*
Expand Down
25 changes: 16 additions & 9 deletions src/org/broad/igv/sam/CoverageTrack.java
Expand Up @@ -174,10 +174,9 @@ public void setDataSource(CoverageDataSource dataSource) {
@Override
public boolean isReadyToPaint(ReferenceFrame frame) {

if (frame.getChrName().equals(Globals.CHR_ALL) || frame.getScale() > dataManager.getMinVisibleScale()) {
if (frame.getChrName().equals(Globals.CHR_ALL) || frame.getScale() > dataManager.getMinVisibleScale()) {
return true; // Nothing to paint
}
else {
} else {
return dataManager.isLoaded(frame);
}
}
Expand Down Expand Up @@ -217,7 +216,7 @@ public boolean isRemoved() {
public void dispose() {
super.dispose();
removed = true;
if(dataManager != null) {
if (dataManager != null) {
dataManager.unsubscribe(this);
}
dataManager = null;
Expand Down Expand Up @@ -303,13 +302,12 @@ private List<LocusScore> getInViewScores(ReferenceFrame frame) {
}
endIdx = Math.max(startIdx + 1, endIdx);

if(inViewScores.size() > 1) {
if (inViewScores.size() > 1) {
return startIdx == 0 && endIdx == inViewScores.size() - 1 ?
inViewScores :
inViewScores.subList(startIdx, endIdx);
}
else {
return inViewScores;
} else {
return inViewScores;
}
}
return inViewScores;
Expand Down Expand Up @@ -399,6 +397,15 @@ public String getValueStringAt(String chr, double position, int mouseX, int mous
return buf.toString();
}

public AlignmentCounts getCounts(String chr, double position, ReferenceFrame frame) {
AlignmentInterval interval = dataManager.getLoadedInterval(frame);
if (interval != null && interval.contains(chr, (int) position, (int) position)) {
return interval.getCounts();
} else {
return null;
}
}

private String getPrecomputedValueString(String chr, double position, ReferenceFrame frame) {

if (dataSource == null) {
Expand Down Expand Up @@ -936,7 +943,7 @@ public void actionPerformed(ActionEvent e) {

public void run() {
setVisible(false);
if(IGV.hasInstance()) IGV.getInstance().getMainPanel().revalidate();
if (IGV.hasInstance()) IGV.getInstance().getMainPanel().revalidate();

}
});
Expand Down
29 changes: 29 additions & 0 deletions src/org/broad/igv/sam/mutreview/BaseCounts.java
@@ -0,0 +1,29 @@
package org.broad.igv.sam.mutreview;


import org.broad.igv.sam.AlignmentCounts;

public class BaseCounts {

public static char [] bases = {'A', 'C', 'T', 'G', 'N'};
public int totalCount;
public int [] negCounts;
public int [] posCounts;
public int delCount;
public int insCount;

public BaseCounts(AlignmentCounts ac, int pos) {

negCounts = new int[5];
posCounts = new int[5];

for(int i=0; i<5; i++) {
negCounts[i] = ac.getNegCount(pos, (byte) bases[i]);
posCounts[i] = ac.getPosCount(pos, (byte) bases[i]);
}
delCount = ac.getDelCount(pos);
insCount = ac.getInsCount(pos);
totalCount = ac.getTotalCount(pos);
}

}
31 changes: 14 additions & 17 deletions src/org/broad/igv/sam/mutreview/VariantReview.fxml
Expand Up @@ -12,60 +12,57 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0"
prefWidth="950.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.broad.igv.sam.mutreview.VariantReviewFX">
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="675.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.broad.igv.sam.mutreview.VariantReviewFX">
<top>

<HBox prefWidth="200.0">
<children>
<Label text="Variant is an artifact ?">
<HBox.margin>
<Insets right="20.0"/>
<Insets right="20.0" />
</HBox.margin>
<font>
<Font name="System Bold" size="24.0"/>
<Font name="System Bold" size="24.0" />
</font>
</Label>
<VBox prefWidth="100.0" spacing="10.0">
<children>
<RadioButton mnemonicParsing="false" text="Yes">
<toggleGroup>
<ToggleGroup fx:id="artifactGroup"/>
<ToggleGroup fx:id="artifactGroup" />
</toggleGroup>
</RadioButton>
<RadioButton mnemonicParsing="false" text="No" toggleGroup="$artifactGroup"/>
<RadioButton mnemonicParsing="false" text="Unknown" toggleGroup="$artifactGroup"/>
<RadioButton mnemonicParsing="false" text="No" toggleGroup="$artifactGroup" />
<RadioButton mnemonicParsing="false" text="Unknown" toggleGroup="$artifactGroup" />
</children>
</VBox>
</children>
<BorderPane.margin>
<Insets left="20.0" top="10.0"/>
<Insets left="20.0" top="10.0" />
</BorderPane.margin>
<padding>
<Insets bottom="10.0" left="10.0" right="1.0" top="10.0"/>
<Insets bottom="10.0" left="10.0" right="1.0" top="10.0" />
</padding>
</HBox>
</top>
<bottom>
<ButtonBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<buttons>
<Button mnemonicParsing="false" text="Cancel"/>
<Button mnemonicParsing="false" onAction="#submit" text="Submit"/>
<Button mnemonicParsing="false" text="Cancel" />
<Button mnemonicParsing="false" onAction="#submit" text="Submit" />
</buttons>
<BorderPane.margin>
<Insets/>
<Insets />
</BorderPane.margin>
<padding>
<Insets bottom="10.0" right="20.0" top="10.0"/>
<Insets bottom="10.0" right="20.0" top="10.0" />
</padding>
</ButtonBar>
</bottom>
<center>
<ImageView fitHeight="500.0" fitWidth="800.0" pickOnBounds="true" preserveRatio="true"
style="-fx-border-color: black; -fx-border-width: 3;" BorderPane.alignment="CENTER">
<ImageView fx:id="imageView" fitHeight="500.0" fitWidth="800.0" pickOnBounds="true" preserveRatio="true" style="-fx-border-color: black; -fx-border-width: 3;" BorderPane.alignment="CENTER">
<BorderPane.margin>
<Insets/>
<Insets />
</BorderPane.margin>
</ImageView>
</center>
Expand Down

0 comments on commit 6d4eaf3

Please sign in to comment.