• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ParsingUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中htsjdk.tribble.util.ParsingUtils的典型用法代码示例。如果您正苦于以下问题:Java ParsingUtils类的具体用法?Java ParsingUtils怎么用?Java ParsingUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParsingUtils类属于htsjdk.tribble.util包,在下文中一共展示了ParsingUtils类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: decodeLine

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
private VariantContext decodeLine(final String line, final boolean includeGenotypes) {
    // the same line reader is not used for parsing the header and parsing lines, if we see a #, we've seen a header line
    if (line.startsWith(VCFHeader.HEADER_INDICATOR)) return null;

    // our header cannot be null, we need the genotype sample names and counts
    if (header == null) throw new TribbleException("VCF Header cannot be null when decoding a record");

    if (parts == null)
        parts = new String[Math.min(header.getColumnCount(), NUM_STANDARD_FIELDS+1)];

    final int nParts = ParsingUtils.split(line, parts, VCFConstants.FIELD_SEPARATOR_CHAR, true);

    // if we have don't have a header, or we have a header with no genotyping data check that we
    // have eight columns.  Otherwise check that we have nine (normal columns + genotyping data)
    if (( (header == null || !header.hasGenotypingData()) && nParts != NUM_STANDARD_FIELDS) ||
            (header != null && header.hasGenotypingData() && nParts != (NUM_STANDARD_FIELDS + 1)) )
        throw new TribbleException("Line " + lineNo + ": there aren't enough columns for line " + line + " (we expected " + (header == null ? NUM_STANDARD_FIELDS : NUM_STANDARD_FIELDS + 1) +
                " tokens, and saw " + nParts + " )");

    return parseVCFLine(parts, includeGenotypes);
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:22,代码来源:OwnVCFCodec.java


示例2: downloadFasta

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
/**
 * Download a fasta file. Also attempts to download the index, and create an index
 * if that download fails
 *
 * @param path     Full source path of fasta
 * @param targetDir     Destination directory for fasta file
 * @param targetName    Destination file name for fasta file
 * @param dialogsParent Parent of progress dialog shown. None shown if null
 * @return
 * @throws IOException
 */
private RunnableResult downloadFasta(String path, File targetDir, String targetName, Frame dialogsParent) throws IOException {
    //Simple case, just need to copy fasta and create index
    File destFile = new File(targetDir, targetName);

    String fastaPath = convertToS3(path);

    //TODO PROMPT TO OVERWRITE IF FILE EXISTS
    URLDownloader urlDownloader = HttpUtils.getInstance().downloadFile(fastaPath, destFile, dialogsParent, "Downloading genome sequence");
    RunnableResult fastaResult = urlDownloader.getResult();
    //If not successful for whatever reason, we don't get the index
    if (!fastaResult.isSuccess()) return fastaResult;

    File destIndexFile = new File(destFile.getAbsolutePath() + ".fai");
    String srcIndexPath = fastaPath + ".fai";
    RunnableResult idxResult = null;
    if (ParsingUtils.resourceExists(srcIndexPath)) {
        idxResult = HttpUtils.getInstance().downloadFile(srcIndexPath, destIndexFile);
    }
    //If remote fasta doesn't exist or download failed, we create our own index
    if (idxResult == null || idxResult == RunnableResult.FAILURE) {
        FastaUtils.createIndexFile(destFile.getAbsolutePath(), destIndexFile.getAbsolutePath());
    }

    return fastaResult;
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:37,代码来源:GenomeManager.java


示例3: loadTabixIndex

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
/**
 * Try to load the tabix index from disk, checking for out of date indexes and old versions
 * @return an Index, or null if we're unable to load
 */
public static Index loadTabixIndex(final File featureFile) {
    Utils.nonNull(featureFile);
    try {
        final String path = featureFile.getAbsolutePath();
        final boolean isTabix = new AbstractFeatureReader.ComponentMethods().isTabix(path, null);
        if (! isTabix){
            return null;
        }
        final String indexPath = ParsingUtils.appendToPath(path, TabixUtils.STANDARD_INDEX_EXTENSION);
        logger.debug("Loading tabix index from disk for file " + featureFile);
        final Index index = IndexFactory.loadIndex(indexPath);
        final File indexFile = new File(indexPath);
        checkIndexVersionAndModificationTime(featureFile, indexFile, index);
        return index;
    } catch (final IOException | RuntimeException e) {
        return null;
    }
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:23,代码来源:IndexUtils.java


示例4: split

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
/**
 * Splits a String using indexOf instead of regex to speed things up.
 * This method produces the same results as {@link String#split(String)} and {@code String.split(String, 0)},
 * but has been measured to be ~2x faster (see {@code StringSplitSpeedUnitTest} for details).
 *
 * @param str       the string to split.
 * @param delimiter the delimiter used to split the string.
 * @return A {@link List} of {@link String} tokens.
 */
public static List<String> split(final String str, final char delimiter) {

    final List<String> tokens;

    if ( str.isEmpty() ) {
        tokens = new ArrayList<>(1);
        tokens.add("");
    }
    else {
        tokens = ParsingUtils.split(str, delimiter);
        removeTrailingEmptyStringsFromEnd(tokens);
    }

    return tokens;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:25,代码来源:Utils.java


示例5: splitAnnotationArgsIntoMap

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
/**
 * Split each element of the given {@link List} into a key and value.
 * Assumes each element of the given {@link List} is formatted as follows:
 *     KEY:VALUE
 * @param annotationArgs {@link List} of strings formatted KEY:VALUE to turn into a {@link Map}.
 * @return A {@link LinkedHashMap} of KEY:VALUE pairs corresponding to entries in the given list.
 */
private LinkedHashMap<String, String> splitAnnotationArgsIntoMap( final List<String> annotationArgs ) {

    final LinkedHashMap<String, String> annotationMap = new LinkedHashMap<>();

    for ( final String s : annotationArgs ) {
        final List<String> keyVal = ParsingUtils.split(s, FuncotatorArgumentDefinitions.MAP_NAME_VALUE_DELIMITER);
        if ( keyVal.size() != 2) {
            throw new UserException.BadInput( "Argument annotation incorrectly formatted: " + s );
        }

        annotationMap.put( keyVal.get(0), keyVal.get(1) );
    }

    return annotationMap;
}
 
开发者ID:broadinstitute,项目名称:gatk,代码行数:23,代码来源:Funcotator.java


示例6: parseAndSetColour

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
private void parseAndSetColour(String[] tokens, int tokenCount, NggbSimpleBedFeature feature) {
    if (tokenCount > COLOUR_OFFSET) {
        String colorString = tokens[COLOUR_OFFSET];
        feature.setColor(ParsingUtils.parseColor(colorString));
        // ThickStart and ThickEnd
        if (NumberUtils.isNumber(tokens[THICK_START_OFFSET])
                && NumberUtils.isNumber(tokens[THICK_END_OFFSET])) {
            feature.setThickStart(Integer.parseInt(tokens[THICK_START_OFFSET]));
            feature.setThickEnd(Integer.parseInt(tokens[THICK_END_OFFSET]));
        }
    }
}
 
开发者ID:react-dev26,项目名称:NGB-master,代码行数:13,代码来源:NggbBedCodec.java


示例7: TabixReaderMod

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
/**
 * @param fn File name of the data file  (used for error messages only)
 * @param idxFn Full path to the index file. Auto-generated if null
 * @param stream Seekable stream from which the data is read
 */
public TabixReaderMod(final String fn, final String idxFn, SeekableStream stream) throws IOException {
    mFn = fn;
    mFp = new BlockCompressedInputStream(stream);
    if(idxFn == null){
        mIdxFn = ParsingUtils.appendToPath(fn, TabixUtils.STANDARD_INDEX_EXTENSION);
    } else {
        mIdxFn = idxFn;
    }
    readIndex();
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:16,代码来源:TabixReaderMod.java


示例8: createExons

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
private void createExons(int start, String[] tokens, FullBEDFeature gene,
                         Strand strand) throws NumberFormatException {

    int cdStart = Integer.parseInt(tokens[6]) + startOffsetValue;
    int cdEnd = Integer.parseInt(tokens[7]);

    int exonCount = Integer.parseInt(tokens[9]);
    String[] exonSizes = new String[exonCount];
    String[] startsBuffer = new String[exonCount];
    ParsingUtils.split(tokens[10], exonSizes, ',');
    ParsingUtils.split(tokens[11], startsBuffer, ',');

    int exonNumber = (strand == Strand.NEGATIVE ? exonCount : 1);

    if (startsBuffer.length == exonSizes.length) {
        for (int i = 0; i < startsBuffer.length; i++) {
            int exonStart = start + Integer.parseInt(startsBuffer[i]);
            int exonEnd = exonStart + Integer.parseInt(exonSizes[i]) - 1;
            gene.addExon(exonStart, exonEnd, cdStart, cdEnd, exonNumber);

            if (strand == Strand.NEGATIVE) {
                exonNumber--;
            } else {
                exonNumber++;
            }
        }
    }
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:29,代码来源:BEDCodecMod.java


示例9: getFilter

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
@VisibleForTesting
static List<String> getFilter(VariantContext vc) {
  if (vc.isFiltered()) {
    return (List<String>) ParsingUtils.sortList(vc.getFilters());
  }
  if (vc.filtersWereApplied()) {
    return Arrays.asList(VCFConstants.PASSES_FILTERS_v4);
  }

  return Arrays.asList(VCFConstants.UNFILTERED);
}
 
开发者ID:verilylifesciences,项目名称:genomewarp,代码行数:12,代码来源:VcfToVariant.java


示例10: initGenotypeTypeField

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
private void initGenotypeTypeField(VariantContext variant) {
    String mutationString = null;
    GenotypeType gtt = GenotypeType.NO_CALL;
    String prefSampleName = VariantReviewPlugin.getPreferentialSampleName();

    //If there is only one sample, or we find the preferential sample,
    //use that data.
    for (String sampleName : variant.getSampleNamesOrderedByName()) {
        boolean isPref = sampleName.equalsIgnoreCase(prefSampleName);
        if (isPref || mutationString == null) {
            if(!variantContext.isBiallelic())
                sampleVC = variantContext.subContextFromSamples(Collections.singleton(sampleName), true);
            else
                sampleVC = variantContext;

            mutationString = ParsingUtils.join(",", ParsingUtils.sortList(sampleVC.getAlleles()));
            Genotype genotype = sampleVC.getGenotype(sampleName);
            gtt = genotype.getType();
            if (isPref) break;
        } else {
            //If we have several samples with different mutations, don't know which
            //to pick. Make that obvious to the user
            if (gtt != sampleVC.getGenotype(sampleName).getType()) {
                mutationString = "./.";
                gtt = GenotypeType.UNAVAILABLE;
            }
        }
    }

    genotypeTypeField.setSelectedItem(gtt);
    mutField.setText(mutationString);
    mutField.setToolTipText(mutationString);
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:34,代码来源:VariantReviewDialog.java


示例11: decodeInts

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
private static final int[] decodeInts(final String string) {
	List<String> split = ParsingUtils.split(string, ',');
	int[] values = new int[split.size()];
	try {
		for (int i = 0; i < values.length; i++) {
			values[i] = Integer.parseInt(split.get(i));
		}
	} catch (final NumberFormatException e) {
		return null;
	}
	return values;
}
 
开发者ID:lindenb,项目名称:jvarkit,代码行数:13,代码来源:KnimeVariantHelper.java


示例12: MixTbiReader

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
public MixTbiReader(final String fn, final AbstractReaderStack stack) throws IOException {
	this(fn, ParsingUtils.appendToPath(fn, TabixUtils.STANDARD_INDEX_EXTENSION), stack);
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:4,代码来源:MixTbiReader.java


示例13: SweepTbiReader

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
public SweepTbiReader(final String fn, final AbstractReaderStack stack) throws IOException {
	 this(fn, ParsingUtils.appendToPath(fn, TabixUtils.STANDARD_INDEX_EXTENSION), stack);
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:4,代码来源:SweepTbiReader.java


示例14: SweepPlusReader

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
public SweepPlusReader(final String fn, final AbstractReaderStack stack, Printter printter) throws IOException {
	this(fn, ParsingUtils.appendToPath(fn, BinIndexWriter.PLUS_INDEX_EXTENSION), ParsingUtils.appendToPath(fn, BinIndexWriter.PLUS_EXTENSION), stack, printter);
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:4,代码来源:SweepPlusReader.java


示例15: MixPlusReader

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
public MixPlusReader(final String fn, final AbstractReaderStack stack, Printter printter) throws IOException {
	this(fn, ParsingUtils.appendToPath(fn, BinIndexWriter.PLUS_INDEX_EXTENSION), ParsingUtils.appendToPath(fn, BinIndexWriter.PLUS_EXTENSION), stack, printter);
}
 
开发者ID:mulinlab,项目名称:vanno,代码行数:4,代码来源:MixPlusReader.java


示例16: transfer

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
public VcfRecord transfer(VariantContext variantContext, boolean withGenotype) {
    String contigName = variantContext.getChr();
    int contigID= refContigInfo.getId(contigName);
    int position = variantContext.getStart();
    String id = variantContext.getID();
    String ref = variantContext.getReference().getDisplayString();

    StringBuilder altBuilder = new StringBuilder();
    if (variantContext.isVariant()) {
        Allele altAllele = variantContext.getAlternateAllele(0);
        String altStr = altAllele.getDisplayString();
        altBuilder.append(altStr);

        for (int i = 1; i < variantContext.getAlternateAlleles().size(); i++) {
            altAllele = variantContext.getAlternateAllele(i);
            altStr = altAllele.getDisplayString();
            altBuilder.append(",");
            altBuilder.append(altStr);
        }
    } else {
        altBuilder.append(VCFConstants.EMPTY_ALTERNATE_ALLELE_FIELD);
    }
    String alt = altBuilder.toString();

    double qual = (!variantContext.hasLog10PError())?  0 : variantContext.getPhredScaledQual();

    String filter = getFilterString(variantContext);

    StringBuilder rest = new StringBuilder();
    // INFO
    final Map<String, String> infoFields = new TreeMap<String, String>();
    for (final Map.Entry<String, Object> field : variantContext.getAttributes().entrySet()) {
        final String outputValue = formatVCFField(field.getValue());
        if (outputValue != null) infoFields.put(field.getKey(), outputValue);
    }
    writeInfoString(infoFields, rest);

    // FORMAT
    if(withGenotype) {
        final GenotypesContext gc = variantContext.getGenotypes();
        if (gc.isLazyWithData() && ((LazyGenotypesContext) gc).getUnparsedGenotypeData() instanceof String) {
            rest.append(VCFConstants.FIELD_SEPARATOR);
            rest.append(((LazyGenotypesContext) gc).getUnparsedGenotypeData().toString());
        } else {
            final List<String> genotypeAttributeKeys = variantContext.calcVCFGenotypeKeys(this.header);
            if (!genotypeAttributeKeys.isEmpty()) {
                final String genotypeFormatString = ParsingUtils.join(VCFConstants.GENOTYPE_FIELD_SEPARATOR, genotypeAttributeKeys);

                rest.append(VCFConstants.FIELD_SEPARATOR);
                rest.append(genotypeFormatString);

                final Map<Allele, String> alleleStrings = buildAlleleStrings(variantContext);
                addGenotypeData(variantContext, alleleStrings, genotypeAttributeKeys, rest);
            }
        }
    }

    return new VcfRecord(contigName, contigID, position, id, ref, alt, qual, filter, rest.toString());
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:60,代码来源:VC2VcfRecordTransfer.java


示例17: getFilterString

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
private String getFilterString(final VariantContext vc) {
    if (vc.isFiltered()) {
        return ParsingUtils.join(";", ParsingUtils.sortList(vc.getFilters()));
    } else if (vc.filtersWereApplied()) return VCFConstants.PASSES_FILTERS_v4;
    else return VCFConstants.UNFILTERED;
}
 
开发者ID:PAA-NCIC,项目名称:SparkSeq,代码行数:7,代码来源:VC2VcfRecordTransfer.java


示例18: getInputStream

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
@Override
public InputStream getInputStream(String input) throws IOException {
	// TODO Auto-generated method stub
	return ParsingUtils.openInputStream(input);
}
 
开发者ID:BGI-flexlab,项目名称:SOAPgaea,代码行数:6,代码来源:VCFLocalLoader.java


示例19: decode

import htsjdk.tribble.util.ParsingUtils; //导入依赖的package包/类
public BEDFeature decode(String[] tokens) {
    int tokenCount = tokens.length;

    // The first 3 columns are non optional for BED.  We will relax this
    // and only require 2.

    if (tokenCount < 2) {
        return null;
    }

    String chr = tokens[0];

    // The BED format uses a first-base-is-zero convention,  Tribble features use 1 => add 1.
    int start = Integer.parseInt(tokens[1]) + startOffsetValue;

    int end = start;
    if (tokenCount > 2) {
    	try {
    		end = Integer.parseInt(tokens[2]);
    	}
    	catch(Exception e) {
    		end = Integer.parseInt(tokens[2].trim());
    	}
    }

    FullBEDFeature feature = new FullBEDFeature(chr, start, end);

    // The rest of the columns are optional.  Stop parsing upon encountering
    // a non-expected value

    // Name
    if (tokenCount > 3) {
        String name = tokens[3].replaceAll("\"", "");
        feature.setName(name);
    }

    // Score
    if (tokenCount > 4) {
        try {
            float score = Float.parseFloat(tokens[4]);
            feature.setScore(score);
        } catch (NumberFormatException numberFormatException) {

            // Unexpected, but does not invalidate the previous values.
            // Stop parsing the line here but keep the feature
            // Don't log, would just slow parsing down.
            return feature;
        }
    }

    // Strand
    if (tokenCount > 5) {
        String strandString = tokens[5].trim();
        char strand = (strandString.length() == 0)
                ? ' ' : strandString.charAt(0);

        if (strand == '-') {
            feature.setStrand(Strand.NEGATIVE);
        } else if (strand == '+') {
            feature.setStrand(Strand.POSITIVE);
        } else {
            feature.setStrand(Strand.NONE);
        }
    }

    //Color
    if (tokenCount > 8) {
        String colorString = tokens[8];
        feature.setColor(ParsingUtils.parseColor(colorString));
    }

    // Coding information is optional
    if (tokenCount > 11) {
        createExons(start, tokens, feature, feature.getStrand());
    }

    return feature;
}
 
开发者ID:rkataine,项目名称:BasePlayer,代码行数:79,代码来源:BEDCodecMod.java



注:本文中的htsjdk.tribble.util.ParsingUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpiChannel类代码示例发布时间:2022-05-22
下一篇:
Java OPSize类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap