本文整理汇总了Java中jloda.util.Pair.getFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.getFirst方法的具体用法?Java Pair.getFirst怎么用?Java Pair.getFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jloda.util.Pair
的用法示例。
在下文中一共展示了Pair.getFirst方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasNext
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* Returns <tt>true</tt> if the iteration has more elements. (In other
* words, returns <tt>true</tt> if <tt>next</tt> would return an element
* rather than throwing an exception.)
*
* @return <tt>true</tt> if the getLetterCodeIterator has more elements.
*/
public boolean hasNext() {
if (error || currentClass == null)
return false;
if (currentCount < currentClass.getFirst())
return true;
currentClass = null;
while (classes.size() > 0) {
currentCount = 0;
Pair<Integer, Long> next = classes.remove(0);
if (next != null && next.getFirst() > 0 && next.getSecond() >= 0) {
try {
classDumpReader.seek(next.getSecond());
} catch (IOException e) {
Basic.caught(e);
return false;
}
currentClass = next;
return true;
}
}
return false;
}
示例2: getSum
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* get the number associated with a key
*
* @param key
* @return number
*/
public int getSum(Integer key) {
Pair<Integer, Long> pair = id2SumAndPos.get(key);
if (pair == null)
return 0;
else
return pair.getFirst();
}
示例3: ReadBlockIteratorRMA2
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* constructor
*
* @param wantReadText
* @param wantMatchData
* @param wantMatchText
* @param minScore
* @param file
* @throws java.io.IOException
*/
public ReadBlockIteratorRMA2(String classification, Collection<Integer> classIds, boolean wantReadText, boolean wantMatchData, boolean wantMatchText, float minScore, float maxExpected, File file) throws IOException {
this.wantReadText = wantReadText;
this.wantMatchData = wantMatchData;
this.wantMatchText = wantMatchText;
this.minScore = minScore;
this.maxExpected = maxExpected;
RMA2File rma2File = new RMA2File(file);
dataIndexReader = rma2File.getDataIndexReader();
InfoSection infoSection = rma2File.loadInfoSection();
rma2Formatter = infoSection.getRMA2Formatter();
if (wantReadText || wantMatchText)
textStorageReader = new TextStorageReader(infoSection.getLocationManager(file));
else
textStorageReader = null;
Map<Integer, Pair<Integer, Long>> map = ClassificationBlockRMA2.getCountAndPos(rma2File, classification);
for (Integer classId : classIds) {
Pair<Integer, Long> pair = map.get(classId);
if (pair != null && pair.getSecond() >= 0) {
classes.add(pair);
totalReads += pair.getFirst();
}
}
// if(pair!=null)
// System.err.println("classId: "+classId+" size: "+pair.getFirst()+" dumpPos: "+pair.getSecond());
if (totalReads > 0) {
currentClass = classes.remove(0);
currentCount = 0;
classDumpReader = rma2File.getClassificationDumpReader(classification);
classDumpReader.seek(currentClass.getSecond());
} else
classDumpReader = null;
}
示例4: ensureArray
import jloda.util.Pair; //导入方法依赖的package包/类
private void ensureArray() {
if (array == null) {
synchronized (values) {
if (array == null) {
array = new double[values.size()];
int i = 0;
for (Pair<Double, String> pair : values) {
array[i++] = pair.getFirst();
}
}
}
}
}
示例5: read
import jloda.util.Pair; //导入方法依赖的package包/类
@Override
public void read(IInputReader reader, long startPos) throws IOException {
reader.seek(startPos);
setFormatDef(reader.readString());
FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
switch (pair.getFirst()) {
case "TotalReads":
setNumberOfReads(reader.readLong());
break;
case "TotalMatches":
setNumberOfMatches(reader.readLong());
break;
case "MaxMatchesPerRead":
setMaxMatchesPerRead(reader.readInt());
break;
case "UseKegg":
setUseKegg(reader.readInt() != 0);
break;
case "UseSeed":
setUseSeed(reader.readInt() != 0);
break;
case "UseCog":
setUseCog(reader.readInt() != 0);
break;
case "UsePfam":
setUsePfam(reader.readInt() != 0);
break;
case "ReadFormat":
setReadFormatDef(reader.readString());
break;
case "MatchFormat":
setMatchFormatDef(reader.readString());
break;
}
}
}
示例6: write
import jloda.util.Pair; //导入方法依赖的package包/类
@Override
public void write(IOutputWriter writer) throws IOException {
writer.writeString(getFormatDef());
FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
formatDefinition.startWrite();
for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
switch (pair.getFirst()) {
case "TotalReads":
formatDefinition.write(writer, "TotalReads", getNumberOfReads());
break;
case "TotalMatches":
formatDefinition.write(writer, "TotalMatches", getNumberOfMatches());
break;
case "MaxMatchesPerRead":
formatDefinition.write(writer, "MaxMatchesPerRead", getMaxMatchesPerRead());
break;
case "UseKegg":
formatDefinition.write(writer, "UseKegg", isUseKegg() ? 1 : 0);
break;
case "UseSeed":
formatDefinition.write(writer, "UseSeed", isUseSeed() ? 1 : 0);
break;
case "UseCog":
formatDefinition.write(writer, "UseCog", isUseCog() ? 1 : 0);
break;
case "UsePfam":
formatDefinition.write(writer, "UsePfam", isUsePfam() ? 1 : 0);
break;
case "ReadFormat":
formatDefinition.write(writer, "ReadFormat", getReadFormatDef());
break;
case "MatchFormat":
formatDefinition.write(writer, "MatchFormat", getMatchFormatDef());
break;
}
}
formatDefinition.finishWrite();
}
示例7: processAlignment
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* compute gap columns for alignment
*
* @param alignment
*/
public void processAlignment(Alignment alignment) {
clear();
if (alignment != null) {
LinkedList<Pair<Integer, Integer>> events = new LinkedList<>();
for (int row = 0; row < alignment.getNumberOfSequences(); row++) {
Lane lane = alignment.getLane(row);
Pair<Integer, Integer> startEvent = new Pair<>(lane.getFirstNonGapPosition(), -1);
events.add(startEvent);
Pair<Integer, Integer> endEvent = new Pair<>(lane.getLastNonGapPosition(), 1);
events.add(endEvent);
}
Pair<Integer, Integer>[] array = (Pair<Integer, Integer>[]) events.toArray(new Pair[events.size()]);
Arrays.sort(array);
int lastStart = 0;
int coverage = 0;
for (Pair<Integer, Integer> event : array) {
if (event.getSecond() == -1) // start
{
if (coverage == 0) {
if (event.getFirst() - 1 >= 0 && lastStart != -1) {
origGapColumns.add(new Pair<>(lastStart, event.getFirst() - 1));
orig2jump.put(lastStart, event.getFirst() - lastStart);
lastStart = -1;
}
}
coverage++;
} else if (event.getSecond() == 1) // end of an interval
{
coverage--;
if (coverage == 0)
lastStart = event.getFirst();
}
}
if (lastStart != -1 && lastStart < alignment.getLength()) {
origGapColumns.add(new Pair<>(lastStart, alignment.getLength()));
orig2jump.put(lastStart, alignment.getLength() - lastStart);
}
originalColumns = alignment.getLength();
for (Pair<Integer, Integer> col : origGapColumns) {
layout2jump.put(col.getFirst() - jumped, orig2jump.get(col.getFirst()));
jumped += orig2jump.get(col.getFirst());
}
/*
for (Pair<Integer, Integer> col : origGapColumns) {
System.err.println("Original gap column: " + col);
System.err.println("jump: " + orig2jump.get(col.getFirst()));
}
for (Pair<Integer, Integer> col : layoutGapColumns) {
System.err.println("Layout gap column: " + col);
System.err.println("jump: " + layout2jump.get(col.getFirst()));
}
System.err.println("Original columns: " + getLastOriginalColumn());
System.err.println("Layout columns: " + getLastLayoutColumn());
*/
}
}
示例8: getPathAndPercent
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* report the taxonomic path and percent
*
* @param readBlock
* @param activeMatchesForTaxa
* @param showTaxonIds
* @param showRank
* @param useOfficialRanksOnly
* @throws IOException
*/
public static String getPathAndPercent(IReadBlock readBlock, BitSet activeMatchesForTaxa, boolean showTaxonIds, boolean showRank, boolean useOfficialRanksOnly) {
final StringBuilder buf = new StringBuilder();
final List<Pair<Integer, Float>> path = TaxonPathAssignment.computeTaxPath(readBlock, activeMatchesForTaxa);
final String expectedPath = "dpcofgs";
int expectedIndex = 0;
for (Pair<Integer, Float> pair : path) {
final Integer taxId = pair.getFirst();
final String taxonName = (showTaxonIds ? "" + taxId : TaxonomyData.getName2IdMap().get(taxId)).replaceAll(";", "\\;");
if (taxonName.equals("root"))
continue;
final int rank = TaxonomyData.getTaxonomicRank(taxId);
String rankName;
if (rank != 0) {
rankName = TaxonomicLevels.getName(rank);
if (rankName == null)
rankName = "?";
} else {
rankName = "?";
}
if (useOfficialRanksOnly && rankName.equals("?"))
continue;
if (showRank && !rankName.equals("?")) {
char letter = Character.toLowerCase(rankName.charAt(0));
if (rank == 127) // domain
letter = 'd';
if (useOfficialRanksOnly) {
while (expectedIndex < expectedPath.length() && letter != expectedPath.charAt(expectedIndex)) {
buf.append(String.format("%c__unknown; %d;", expectedPath.charAt(expectedIndex), (int) (float) pair.getSecond()));
expectedIndex++;
}
expectedIndex++;
}
buf.append(String.format("%c__%s; %d;", letter, taxonName, (int) (float) pair.getSecond()));
} else
buf.append(" ").append(taxonName).append("; ").append((int) (float) pair.getSecond()).append(";");
}
return buf.toString();
}
示例9: read
import jloda.util.Pair; //导入方法依赖的package包/类
@Override
public void read(IInputReader reader, long startPos) throws IOException {
reader.seek(startPos);
setFormatDef(reader.readString());
doKegg = doSeed = doCog = doPfam = false;
FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
{
switch (pair.getFirst()) {
case "ClassificationBlockFormat":
setClassificationBlockFormat(reader.readString());
break;
case "TaxStart":
setStart(ClassificationType.Taxonomy, reader.readLong());
break;
case "TaxEnd":
setEnd(ClassificationType.Taxonomy, reader.readLong());
break;
case "KeggStart":
setStart(ClassificationType.KEGG, reader.readLong());
doKegg = true;
break;
case "KeggEnd":
setEnd(ClassificationType.KEGG, reader.readLong());
break;
case "SeedStart":
setStart(ClassificationType.SEED, reader.readLong());
doSeed = true;
break;
case "SeedEnd":
setEnd(ClassificationType.SEED, reader.readLong());
break;
case "CogStart":
setStart(ClassificationType.COG, reader.readLong());
doCog = true;
break;
case "CogEnd":
setEnd(ClassificationType.COG, reader.readLong());
break;
case "PfamStart":
setStart(ClassificationType.PFAM, reader.readLong());
doPfam = true;
break;
case "PfamEnd":
setEnd(ClassificationType.PFAM, reader.readLong());
break;
}
}
}
}
示例10: write
import jloda.util.Pair; //导入方法依赖的package包/类
@Override
public void write(IOutputWriter writer) throws IOException {
writer.writeString(getFormatDef());
FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
formatDefinition.startWrite();
for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
{
switch (pair.getFirst()) {
case "ClassificationBlockFormat":
formatDefinition.write(writer, "ClassificationBlockFormat", getClassificationBlockFormat());
break;
case "TaxStart":
formatDefinition.write(writer, "TaxStart", getStart(ClassificationType.Taxonomy));
break;
case "TaxEnd":
formatDefinition.write(writer, "TaxEnd", getEnd(ClassificationType.Taxonomy));
break;
case "KeggStart":
formatDefinition.write(writer, "KeggStart", getStart(ClassificationType.KEGG));
break;
case "KeggEnd":
formatDefinition.write(writer, "KeggEnd", getEnd(ClassificationType.KEGG));
break;
case "SeedStart":
formatDefinition.write(writer, "SeedStart", getStart(ClassificationType.SEED));
break;
case "SeedEnd":
formatDefinition.write(writer, "SeedEnd", getEnd(ClassificationType.SEED));
break;
case "CogStart":
formatDefinition.write(writer, "CogStart", getStart(ClassificationType.COG));
break;
case "CogEnd":
formatDefinition.write(writer, "CogEnd", getEnd(ClassificationType.COG));
break;
case "PfamStart":
formatDefinition.write(writer, "PfamStart", getStart(ClassificationType.PFAM));
break;
case "PfamEnd":
formatDefinition.write(writer, "PfamEnd", getEnd(ClassificationType.PFAM));
break;
}
}
}
formatDefinition.finishWrite();
}
示例11: read
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* read from an RMA3 file
*
* @param reader
* @throws IOException
*/
public void read(IInputReader reader, long startPos) throws IOException {
reader.seek(startPos);
setFormatDef(reader.readString());
FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
switch (pair.getFirst()) {
case "Creator":
setCreator(reader.readString());
break;
case "CreationDate":
setCreationDate(reader.readLong());
break;
case "AlignmentsFile":
setAlignmentFile(reader.readString());
break;
case "AlignmentFileFormat":
setAlignmentFileFormat(reader.readString());
break;
case "AlignmentFileSize":
setAlignmentFileSize(reader.readLong());
break;
case "ReadsFile":
setReadsFile(reader.readString());
break;
case "ReadsFileFormat":
setReadsFileFormat(reader.readString());
break;
case "ReadsFileSize":
setReadsFileSize(reader.readLong());
break;
case "BlastMode":
setBlastMode(reader.readString());
break;
case "MatchesStart":
setMatchesStart(reader.readLong());
break;
case "MatchesFooter":
setMatchesFooter(reader.readLong());
break;
case "ClassificationsStart":
setClassificationsStart(reader.readLong());
break;
case "ClassificationsFooter":
setClassificationsFooter(reader.readLong());
break;
case "AuxStart":
setAuxStart(reader.readLong());
break;
case "AuxFooter":
setAuxFooter(reader.readLong());
break;
case "FileFooter":
setFileFooter(reader.readLong());
break;
}
}
}
示例12: write
import jloda.util.Pair; //导入方法依赖的package包/类
/**
* write to an RMA3 file
*
* @param writer
* @return location of fileFooter in file
* @throws IOException
*/
public void write(IOutputWriter writer) throws IOException {
writer.writeString(getFormatDef());
final FormatDefinition formatDefinition = FormatDefinition.fromString(getFormatDef());
formatDefinition.startWrite();
for (Pair<String, FormatDefinition.Type> pair : formatDefinition.getList()) {
{
switch (pair.getFirst()) {
case "Creator":
formatDefinition.write(writer, "Creator", getCreator());
break;
case "CreationDate":
formatDefinition.write(writer, "CreationDate", getCreationDate());
break;
case "AlignmentsFile":
formatDefinition.write(writer, "AlignmentsFile", getAlignmentFile());
break;
case "AlignmentFileFormat":
formatDefinition.write(writer, "AlignmentFileFormat", getAlignmentFileFormat());
break;
case "AlignmentFileSize":
formatDefinition.write(writer, "AlignmentFileSize", getAlignmentFileSize());
break;
case "ReadsFile":
formatDefinition.write(writer, "ReadsFile", getReadsFile());
break;
case "ReadsFileFormat":
formatDefinition.write(writer, "ReadsFileFormat", getReadsFileFormat());
break;
case "ReadsFileSize":
formatDefinition.write(writer, "ReadsFileSize", getReadsFileSize());
break;
case "BlastMode":
formatDefinition.write(writer, "BlastMode", getBlastMode());
break;
case "MatchesStart":
formatDefinition.write(writer, "MatchesStart", getMatchesStart());
break;
case "MatchesFooter":
formatDefinition.write(writer, "MatchesFooter", getMatchesFooter());
break;
case "ClassificationsStart":
formatDefinition.write(writer, "ClassificationsStart", getClassificationsStart());
break;
case "ClassificationsFooter":
formatDefinition.write(writer, "ClassificationsFooter", getClassificationsFooter());
break;
case "AuxStart":
formatDefinition.write(writer, "AuxStart", getAuxStart());
break;
case "AuxFooter":
formatDefinition.write(writer, "AuxFooter", getAuxFooter());
break;
case "FileFooter":
formatDefinition.write(writer, "FileFooter", getFileFooter());
break;
}
}
}
formatDefinition.finishWrite();
}