Beispiel #1
0
  public static List<FeatureTrack> loadTracks(
      Iterable<Feature> features,
      ResourceLocator locator,
      Genome genome,
      TrackProperties trackProperties) {

    FeatureCollectionSource source = new FeatureCollectionSource(features, genome);

    // Load into FeatureDB for searching
    if (IGV.hasInstance() || Globals.isTesting()) {
      Set<String> chrs = source.getChrs();
      for (String chr : chrs) {
        List<Feature> feats = source.getFeatures(chr);
        for (Feature f : feats) {
          if (f instanceof NamedFeature) {
            FeatureDB.addFeature((NamedFeature) f);
          }
        }
      }
    }

    FeatureTrack track = new FeatureTrack(locator, source);
    track.setName(locator.getTrackName());
    track.setRendererClass(IGVFeatureRenderer.class);
    track.setHeight(45);

    if (trackProperties != null) {
      track.setProperties(trackProperties);
    }

    List<FeatureTrack> tracks = new ArrayList();
    tracks.add(track);

    return tracks;
  }
Beispiel #2
0
 public static String getGSUser() throws IOException {
   if (gsUser == null && !Globals.isTesting()) {
     BufferedReader br = null;
     try {
       File tokenFile = getUsernameFile();
       if (tokenFile.exists()) {
         br = new BufferedReader(new FileReader(tokenFile));
         gsUser = br.readLine().trim();
       }
     } finally {
       try {
         if (br != null) br.close();
       } catch (Exception e) {
       }
     }
   }
   return gsUser;
 }
Beispiel #3
0
  public static void setGSUser(String newUser) {
    if (gsUser == null || !gsUser.equals(newUser)) {
      gsUser = newUser;

      if (Globals.isTesting()) {
        return;
      }

      File gsDir = getTokenSaveDir();
      if (!gsDir.isDirectory()) {
        log.error(
            "Could not store token for SSO.  File "
                + gsDir.getAbsolutePath()
                + "exists and is not a directory.");
        return; // someone made a file with this name...
      }
      File userFile = getUsernameFile();
      if (userFile.exists()) userFile.delete();
      writeToFile(gsUser, userFile);
    }
  }
Beispiel #4
0
 public static String getGSToken() {
   if (gsToken == null && !Globals.isTesting()) {
     File file = GSUtils.getTokenFile();
     if (file.exists()) {
       BufferedReader br = null;
       try {
         br = new BufferedReader(new FileReader(file));
         gsToken = br.readLine();
       } catch (IOException e) {
         log.error("Error reading GS cookie", e);
       } finally {
         if (br != null)
           try {
             br.close();
           } catch (IOException e) {
             // Ignore
           }
       }
     }
   }
   return gsToken;
 }
Beispiel #5
0
  public static void setGSToken(String newToken) {
    if (gsToken == null || !gsToken.equals(newToken)) {
      gsToken = newToken;

      if (Globals.isTesting()) {
        return;
      }

      BufferedWriter bw = null;
      File gsDir = getTokenSaveDir();
      if (!gsDir.isDirectory()) {
        log.error(
            "Could not store token for SSO.  File "
                + gsDir.getAbsolutePath()
                + "exists and is not a directory.");
        return; // someone made a file with this name...
      }
      File tokenFile = getTokenFile();
      if (tokenFile.exists()) tokenFile.delete();
      writeToFile(gsToken, tokenFile);
    }
  }