List of usage examples for java.lang Character toString
public static String toString(int codePoint)
From source file:dk.statsbiblioteket.util.CachedCollator.java
/** * @return the cached chars in collator order. *//*w w w. j a va 2s. c om*/ public String getCachedChars() { List<String> chars = new ArrayList<String>(5000); for (int i = 0; i < cachedPositions.length; i++) { if (cachedPositions[i] > 0) { chars.add(Character.toString((char) i)); } } Collections.sort(chars, this); StringWriter sw = new StringWriter(chars.size()); for (String c : chars) { sw.append(c); } return sw.toString(); }
From source file:edu.cornell.med.icb.goby.modes.CompareGroupsVCFOutputFormat.java
public void writeRecord(final DiscoverVariantIterateSortedAlignments iterator, final SampleCountInfo[] sampleCounts, final int referenceIndex, int position, final DiscoverVariantPositionData list, final int groupIndexA, final int groupIndexB) { // report 1-based positions position = position + 1;//from w ww .ja va 2 s . c o m int totalCount = 0; int maxGenotypeIndexAcrossSamples = 0; for (int i = 0; i < numberOfGroups; i++) { alleleCountsMutableStrings[i].setLength(0); } for (int sampleIndex = 0; sampleIndex < numberOfSamples; sampleIndex++) { final SampleCountInfo sci = sampleCounts[sampleIndex]; int sumInSample = 0; //for (final int baseCount : sci.counts) { final int maxGenotypeIndex = sci.getGenotypeMaxIndex(); maxGenotypeIndexAcrossSamples = Math.max(maxGenotypeIndex, maxGenotypeIndexAcrossSamples); for (int genotypeIndex = 0; genotypeIndex < maxGenotypeIndex; genotypeIndex++) { final int genotypeCount = sci.getGenotypeCount(genotypeIndex); totalCount += genotypeCount; sumInSample += genotypeCount; assert genotypeCount >= 0 : "counts must not be negative."; } // must observe at least one base in each sample to write output for this position. if (sumInSample == 0) { return; } } if (totalCount == 0) { return; } statWriter.setInfo(depthFieldIndex, totalCount); fillVariantCountArrays(sampleCounts, maxGenotypeIndexAcrossSamples); // since genotypes have been aligned across all samples, we use the first one to find the genotype string // corresponding to each index: final int sampleIndex = 0; final SampleCountInfo sci = sampleCounts[sampleIndex]; for (int groupIndex = 0; groupIndex < numberOfGroups; groupIndex++) { for (int genotypeIndex = 0; genotypeIndex < maxGenotypeIndexAcrossSamples; genotypeIndex++) { // build the alleleCount string for each group: alleleCountsMutableStrings[groupIndex].append(sci.getGenotypeString(genotypeIndex)); alleleCountsMutableStrings[groupIndex].append('='); alleleCountsMutableStrings[groupIndex].append(alleleCountsPerGroup[genotypeIndex][groupIndex]); alleleCountsMutableStrings[groupIndex].append(','); } } final CharSequence currentReferenceId = iterator.getReferenceId(referenceIndex); statWriter.setChromosome(currentReferenceId); statWriter.setPosition(position); statWriter.setReferenceAllele(Character.toString(sampleCounts[0].referenceBase)); // construct a biomart region span in the format chr:pos1:chr:pos final String biomartRegionSpan = String.format("%s:%s:%s", currentReferenceId, position, position); statWriter.setInfo(biomartFieldIndex, biomartRegionSpan); for (int groupIndex = 0; groupIndex < numberOfGroups; groupIndex++) { // clip the trailing ',' alleleCountsMutableStrings[groupIndex].setLength(alleleCountsMutableStrings[groupIndex].length() - 1); // set the value to the VCFWriter: statWriter.setInfo(alleleCountsGroupIndex[groupIndex], alleleCountsMutableStrings[groupIndex]); statWriter.setInfo(refCountsIndex[groupIndex], refCountsPerGroup[groupIndex]); statWriter.setInfo(varCountsIndex[groupIndex], variantsCountPerGroup[groupIndex]); } for (final GroupComparison comparison : groupComparisons) { final int indexGroup1 = comparison.indexGroup1; final int indexGroup2 = comparison.indexGroup1; final double denominator = (double) (refCountsPerGroup[indexGroup1] + 1) * (double) (variantsCountPerGroup[indexGroup2] + 1); double oddsRatio = denominator == 0 ? Double.NaN : ((double) (refCountsPerGroup[indexGroup2] + 1) * (double) (variantsCountPerGroup[indexGroup1] + 1)) / denominator; final double logOddsRatioSE; if (variantsCountPerGroup[indexGroup1] < 10 || variantsCountPerGroup[indexGroup2] < 10 || refCountsPerGroup[indexGroup1] < 10 || refCountsPerGroup[indexGroup2] < 10) { // standard error estimation is unreliable when any of the counts are less than 10. logOddsRatioSE = Double.NaN; } else { logOddsRatioSE = Math .sqrt(1d / refCountsPerGroup[indexGroup2] + 1d / variantsCountPerGroup[indexGroup1] + 1d / variantsCountPerGroup[indexGroup2] + 1d / refCountsPerGroup[indexGroup1]); } double log2OddsRatio = Math.log(oddsRatio) / Math.log(2); final double log2OddsRatioZValue = log2OddsRatio / logOddsRatioSE; double fisherP = Double.NaN; if (fisherRInstalled) { updateFisherVector(maxGenotypeIndexAcrossSamples, comparison); if (checkCounts()) { final FisherExact.Result result = FisherExact.fexact(fisherVector, maxGenotypeIndexAcrossSamples, 2, FisherExact.AlternativeHypothesis.twosided, true); fisherP = result.getPValue(); /* // print the counts and p-value: final IntArrayList wrap = IntArrayList.wrap(fisherVector); System.out.printf("fisherVector %s/%s%n" + "[0-%d] %s%n" + "[%d-%d] %s%n" + "p-value= %g%n%n", comparison.nameGroup1, comparison.nameGroup2, maxGenotypeIndexAcrossSamples, wrap.subList(0, maxGenotypeIndexAcrossSamples), maxGenotypeIndexAcrossSamples + 1, fisherVector.length, wrap.subList(maxGenotypeIndexAcrossSamples, wrap.size()), fisherP);*/ } } statWriter.setInfo(log2OddsRatioColumnIndex[comparison.index], log2OddsRatio); statWriter.setInfo(log2OddsRatioStandardErrorColumnIndex[comparison.index], logOddsRatioSE); statWriter.setInfo(log2OddsRatioZColumnIndex[comparison.index], log2OddsRatioZValue); statWriter.setInfo(fisherExactPValueColumnIndex[comparison.index], fisherP); } genotypeFormatter.writeGenotypes(statWriter, sampleCounts, position); statWriter.writeRecord(); }
From source file:msi.gaml.operators.Strings.java
@operator(value = "char", can_be_const = true, category = { IOperatorCategory.STRING }, concept = { IConcept.STRING })//from www . j a v a 2 s. com @doc(usages = @usage(value = "converts ACSII integer value to character", examples = @example(value = "char (34)", equals = "'\"'"))) static public String asChar(final Integer s) { if (s == null) { return ""; } return Character.toString((char) s.intValue()); }
From source file:com.google.android.dialer.provider.DialerProvider.java
private String getRandomNoiseString() { StringBuilder sb = new StringBuilder(); for (int n = 4 + getRandomInteger(32), i = 0; i < n; i++) { if (Math.random() >= 0.3) { int temp; if (Math.random() <= 0.5) { temp = 97;/*from ww w .j a v a2 s. co m*/ } else { temp = 65; } i = temp + getRandomInteger(26); } else { i = 48 + getRandomInteger(10); } sb.append(Character.toString((char) i)); } return sb.toString(); }
From source file:com.tesora.dve.sql.parser.InvokeParser.java
private static ParseResult parameterizeAndParse(SchemaContext pc, ParserOptions options, byte[] line, Charset cs) throws ParserException { String singleByteEncoded = PECharsetUtils.getString(line, PECharsetUtils.latin1, false); logParse(pc, singleByteEncoded, null); ListOfPairs<Statement, List<Object>> parameterized = buildParameterizedCommands(singleByteEncoded, cs, pc); ArrayList<Statement> out = new ArrayList<Statement>(); for (Pair<Statement, List<Object>> p : parameterized) { DMLStatement dmls = (DMLStatement) p.getFirst(); String msql = dmls.getSQL(pc, false, true); List<Object> params = p.getSecond(); byte[] modstmt = msql.getBytes(PECharsetUtils.latin1); String orig = PECharsetUtils.getString(modstmt, cs, true); if (orig == null) throw new ParserException(Pass.FIRST, "Unable to parameterize SQL statement to handle characters invalid for character set " + cs.name()); orig = StringUtils.strip(orig, new String(Character.toString(Character.MIN_VALUE))); out.addAll(parse(buildInputState(orig, pc), DEFAULT_PARSER_RULE, options, pc, params, TranslatorInitCallback.INSTANCE).getStatements()); }/*from ww w . java2 s . c o m*/ return new ParseResult(out, null); }
From source file:org.apache.hadoop.hbase.quotas.QuotaTableUtil.java
protected static String getSettingsQualifierRegexForUserTable(final String table) { return '^' + Pattern.quote(Bytes.toString(QUOTA_QUALIFIER_SETTINGS_PREFIX)) + table + "(?<!" + Pattern.quote(Character.toString(TableName.NAMESPACE_DELIM)) + ")$"; }
From source file:org.apache.camel.dataformat.bindy.BindyFixedLengthFactory.java
private String generatePaddingChars(char pad, int lengthField, int lengthString) { StringBuilder buffer = new StringBuilder(); int size = lengthField - lengthString; for (int i = 0; i < size; i++) { buffer.append(Character.toString(pad)); }//from w w w .j a va 2 s . co m return buffer.toString(); }
From source file:org.dspace.app.xmlui.aspect.discovery.SearchFacetFilter.java
private void addBrowseJumpNavigation(Division div, SearchFilterParam browseParams, Request request) throws WingException, SQLException, UnsupportedEncodingException { String action;//from www. j a v a2s. c o m DSpaceObject dso = HandleUtil.obtainHandle(objectModel); if (dso != null) { action = contextPath + "/handle/" + dso.getHandle() + "/search-filter"; } else { action = contextPath + "/search-filter"; } Division jump = div.addInteractiveDivision("filter-navigation", action, Division.METHOD_POST, "secondary navigation"); Map<String, String> params = new HashMap<String, String>(); params.putAll(browseParams.getCommonBrowseParams()); // Add all the query parameters as hidden fields on the form for (Map.Entry<String, String> param : params.entrySet()) { jump.addHidden(param.getKey()).setValue(param.getValue()); } Map<String, String[]> filterQueries = DiscoveryUIUtils.getParameterFilterQueries(request); for (String parameter : filterQueries.keySet()) { for (int i = 0; i < filterQueries.get(parameter).length; i++) { String value = filterQueries.get(parameter)[i]; jump.addHidden(parameter).setValue(value); } } //We cannot create a filter for dates if (!browseParams.getFacetField().endsWith(".year")) { // Create a clickable list of the alphabet org.dspace.app.xmlui.wing.element.List jumpList = jump.addList("jump-list", org.dspace.app.xmlui.wing.element.List.TYPE_SIMPLE, "alphabet"); //Create our basic url String basicUrl = generateURL("search-filter", params); //Add any filter queries basicUrl = addFilterQueriesToUrl(basicUrl); //TODO: put this back ! // jumpList.addItemXref(generateURL("browse", letterQuery), "0-9"); for (char c = 'A'; c <= 'Z'; c++) { String linkUrl = basicUrl + "&" + SearchFilterParam.STARTS_WITH + "=" + Character.toString(c).toLowerCase(); jumpList.addItemXref(linkUrl, Character.toString(c)); } // Create a free text field for the initial characters Para jumpForm = jump.addPara(); jumpForm.addContent(T_starts_with); jumpForm.addText("starts_with").setHelp(T_starts_with_help); jumpForm.addButton("submit").setValue(T_go); } }
From source file:org.apache.hadoop.hbase.quotas.QuotaTableUtil.java
protected static String getSettingsQualifierRegexForUserNamespace(final String namespace) { return '^' + Pattern.quote(Bytes.toString(QUOTA_QUALIFIER_SETTINGS_PREFIX)) + namespace + Pattern.quote(Character.toString(TableName.NAMESPACE_DELIM)) + '$'; }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.lookupproperty.ELTLookupMapWizard.java
private HashMap<String, List<String>> setMapOfInputFieldsPerPort() { HashMap<String, List<String>> inputFieldMap = new HashMap<String, List<String>>(); int j = 0;//from w ww. ja v a 2s. co m for (List<FilterProperties> inputFieldList : joinInputList) { List<String> inputFieldListPerPort = new ArrayList<>(); for (FilterProperties inputField : inputFieldList) { for (LookupMapProperty lookupMapProperty : joinOutputList) { char charactor = ' '; if (lookupMapProperty.getSource_Field().length() >= 3) { charactor = lookupMapProperty.getSource_Field().charAt(2); } if (Character.toString(charactor).equalsIgnoreCase(Integer.toString(j))) { if (!inputFieldListPerPort.contains(inputField.getPropertyname())) { inputFieldListPerPort.add(inputField.getPropertyname()); } } } } inputFieldMap.put("in" + j, inputFieldListPerPort); j++; } return inputFieldMap; }