Ejemplo n.º 1
0
  public Set<String> getSamples() {
    HashSet<String> uniqueSamples = new HashSet<String>(table.size());

    for (Entry e : table) uniqueSamples.add(e.getSampleId());

    return uniqueSamples;
  }
Ejemplo n.º 2
0
  public Set<String> getSamplesInLane(int lane) {
    if (lane <= 0) throw new IllegalArgumentException("Invalid negative lane number " + lane);

    HashSet<String> samples = new HashSet<String>(table.size() / 8);
    for (Entry e : this) {
      if (lane == e.getLane()) samples.add(e.getSampleId());
    }

    return samples;
  }
Ejemplo n.º 3
0
 /**
  * Return a string that describes the statistics for the top n entries, sorted by descending
  * order of total time spent dealing with the query. This will always include the totals entry
  * in the first position.
  *
  * @param n the desired number of entries to describe
  * @return a string describing the statistics for the top n entries
  */
 public synchronized String toStringTop(int n) {
   StringBuilder out = new StringBuilder();
   List<Entry> list = entries();
   if (list.isEmpty()) return "<no queries executed>";
   Collections.sort(list, TOTAL_TIME_DESCENDING);
   int maxCountLength = COUNT_FORMAT.format(list.get(0).numQueries).length();
   double totalDuration = list.get(0).queryTime;
   for (Entry entry : list.subList(0, Math.min(n, list.size())))
     out.append(entry.toString(maxCountLength, totalDuration)).append('\n');
   return out.toString();
 }
Ejemplo n.º 4
0
  public void run() {
    while (true) {

      try {
        // System.out.println(r+": Take(wait)");
        // String[] info = q.take();
        String blogID = q.poll(60, TimeUnit.SECONDS);
        if (blogID == null) {
          System.out.println("Poll.Timeout");
          continue;
        }

        // System.out.println(r+": Take(get) : "+blogID);

        if (blogID == NO_MORE_WORK) {
          break;
        }

        URL feedUrl = new URL("http://www.blogger.com/feeds/" + blogID + "/comments/default");
        Query myQuery = new Query(feedUrl);
        myQuery.setMaxResults(25);

        System.out.print(r + "+,");
        Feed resultFeed = myService.query(myQuery, Feed.class);

        for (Entry entry : resultFeed.getEntries()) {
          if (entry.getAuthors().get(0).getUri() != null) {
            String profileID = entry.getAuthors().get(0).getUri().replaceAll("[^\\d]", "");
            if (profileID.length() == 20) {
              try {
                myStm.executeUpdate(
                    "INSERT IGNORE INTO author SET profileID = '" + profileID + "'");
                // System.out.print(r+"+,");
              } catch (Exception e) {
              }
            }
          }
        }

      } catch (Exception e) {
        System.out.print(r + "ERR,");
      }
    }

    System.out.println("Bye(" + r + ")");
    try {
      myStm.close();
    } catch (Exception e) {
    }
  }
Ejemplo n.º 5
0
  private void insertRecord(String line) throws FormatException {
    String[] fields = line.split(",");
    if (fields.length < 9)
      throw new FormatException(
          "Too few columns in sample sheet.  Expecing at least 9 but found "
              + fields.length
              + ". Line: "
              + line);

    // Format is CSV with these columns:
    // "FCID","Lane","SampleID","SampleRef","Index","Description","Control","Recipe","Operator"
    // All text fields are quoted (all except Lane)

    // remove external quotes and whitespace from all string fields (even spaces within the quotes)
    for (int i = 0; i < fields.length; ++i) {
      quoteMatcher.reset(fields[i]);
      fields[i] = quoteMatcher.replaceAll("").trim();
    }

    Entry entry;
    try {
      entry = Entry.createEntry(fields);
    } catch (IllegalArgumentException e) {
      throw new FormatException(e.getMessage() + ". Line: " + line);
    }

    table.add(entry);
  }
Ejemplo n.º 6
0
    public static Entry createEntry(String[] fields) {
      if (fields.length < 9)
        throw new IllegalArgumentException(
            "Too few fields to build a sample sheet entry.  Expecing at least 9 but found "
                + fields.length
                + ".");

      Entry e = new Entry();
      e.setFlowcellId(fields[0]);
      e.setLane(Integer.parseInt(fields[1]));
      e.setSampleId(fields[2]);
      e.setSampleRef(fields[3]);
      e.setIndex(fields[4]);
      e.setDescription(fields[5]);
      e.setControl(fields[6]);
      e.setRecipe(fields[7]);
      e.setOperator(fields[8]);
      return e;
    }
Ejemplo n.º 7
0
  public void loadTable(Reader in) throws IOException, FormatException {
    table = new ArrayList<Entry>(InitNumEntries);

    String line = null;
    LineNumberReader input = new LineNumberReader(in);

    line = input.readLine();
    if (line == null) throw new FormatException("Empty sample sheet");
    // Verify that heading is as expected, ignoring quotes and case
    if (!line.replaceAll("\"", "").toLowerCase().startsWith(ExpectedHeading))
      throw new FormatException(
          "Unexpected heading!  Expected:\n" + ExpectedHeading + "\nFound:\n" + line);

    line = input.readLine();
    while (line != null) {
      insertRecord(line);
      line = input.readLine();
    }

    if (table.size() > 1) {
      // Check for duplicates barcodes in the same lane
      // start by sorting the table by lane
      Collections.sort(
          table,
          new Comparator<Entry>() {
            @Override
            public int compare(Entry a, Entry b) {
              return a.getLane() - b.getLane();
            }
          });
      HashSet<String> samplesInLane = new HashSet<String>();
      int currentLane = table.get(0).getLane();
      for (Entry e : table) // table is an ArrayList of Entries
      {
        if (e.getLane() == currentLane) {
          if (samplesInLane.contains(e.getIndex()))
            throw new FormatException(
                "index " + e.getIndex() + " appears twice for the same lane " + currentLane);
          else samplesInLane.add(e.getIndex());
        } else {
          // lane change
          samplesInLane.clear();
          samplesInLane.add(e.getIndex());
          currentLane = e.getLane();
        }
      }
    }
  }