Esempio n. 1
0
static jint Pattern_compileImpl(JNIEnv* env, jclass, jstring javaRegex, jint flags) {
    flags |= UREGEX_ERROR_ON_UNKNOWN_ESCAPES;

    UErrorCode status = U_ZERO_ERROR;
    UParseError error;
    error.offset = -1;

    ScopedJavaUnicodeString regex(env, javaRegex);
    UnicodeString& regexString(regex.unicodeString());
    RegexPattern* result = RegexPattern::compile(regexString, flags, error, status);
    if (!U_SUCCESS(status)) {
        throwPatternSyntaxException(env, status, javaRegex, error);
    }
    return static_cast<jint>(reinterpret_cast<uintptr_t>(result));
}
Esempio n. 2
0
// save autoreplace entries to configuration
void Autoreplace_Config::saveSettings()
{
  // get configuration object
  KSharedConfigPtr config=KGlobal::config();

  // delete all patterns
  config->deleteGroup("Autoreplace List");
  // create new empty autoreplace group

  KConfigGroup grp = config->group("Autoreplace List");

  // create empty list
  QList<QStringList> newList=currentAutoreplaceList();

  // check if there are any patterns in the list view
  if(newList.count())
  {
    // go through all patterns and save them into the configuration
    QString regexString("Regex");
    QString directString("Direction");
    QString patternString("Pattern");
    QString replaceString("Replace");
    for(int index=0;index<newList.count();index++)
    {
        // write the current entry's pattern and replacement (adds a "#" to preserve blanks at the end of the line)
        QString indexString(QString::number(index));
        QStringList definition = newList[index];
        grp.writeEntry(regexString + indexString,definition.at(0)); //regex status
        grp.writeEntry(directString + indexString,definition.at(1)); //direction
        grp.writeEntry(patternString + indexString,QString(definition.at(2)+'#')); //pattern
        grp.writeEntry(replaceString + indexString,QString(definition.at(3)+'#')); //replace

    } // for
  }
  // if there were no entries at all, write a dummy entry to prevent KConfigXT from "optimizing"
  // the group out, which would in turn make konvi restore the default entries
  else
    grp.writeEntry("Empty List",QString());

  // set internal autoreplace list
  Preferences::setAutoreplaceList(newList);

  // remember autoreplace list for hasChanged()
  m_oldAutoreplaceList=newList;
}
Esempio n. 3
0
flowcell::Layout FastqFlowcell::createFilteredFlowcell(
    const std::string &tilesFilter,
    const boost::filesystem::path &baseCallsDirectory,
    const bool compressed,
    const unsigned laneNumberMax,
    const unsigned readNameLength,
    std::string useBasesMask,
    const bool allowVariableFastqLength,
    const char fastqQ0,
    const std::string &seedDescriptor,
    const unsigned seedLength,
    const reference::ReferenceMetadataList &referenceMetadataList,
    unsigned &firstPassSeeds)
{

    FastqPathPairList flowcellFilePaths = findFastqPathPairs(compressed, laneNumberMax, baseCallsDirectory);
    if (flowcellFilePaths.empty())
    {
        const boost::format message = boost::format("\n   *** Could not find any fastq lanes in: %s ***\n") %
            baseCallsDirectory;
        BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str()));
    }

    FastqFlowcellInfo flowcellInfo = parseFastqFlowcellInfo(flowcellFilePaths, allowVariableFastqLength, fastqQ0, readNameLength);

    std::vector<unsigned int> readLengths;
    if (flowcellInfo.readLengths_.first)
    {
        readLengths.push_back(flowcellInfo.readLengths_.first);
    }
    if (flowcellInfo.readLengths_.second)
    {
        readLengths.push_back(flowcellInfo.readLengths_.second);
    }

    if ("default" == useBasesMask)
    {
        if (readLengths.size() == 1)
        {
            useBasesMask = "y*n";
        }
        else if (readLengths.size() == 2)
        {
            useBasesMask = "y*n,y*n";
        }
        else
        {
            const boost::format message =
                boost::format("\n   *** Could not guess the use-bases-mask for '%s', please supply the explicit value ***\n") %
                baseCallsDirectory.string();
            BOOST_THROW_EXCEPTION(common::InvalidOptionException(message.str()));
        }
    }

    std::vector<unsigned int> readFirstCycles;

    ParsedUseBasesMask parsedUseBasesMask;
    alignment::SeedMetadataList seedMetadataList;
    if (!readLengths.empty())
    {
        parsedUseBasesMask = parseUseBasesMask(readFirstCycles, readLengths, seedLength, useBasesMask, baseCallsDirectory);
        seedMetadataList = parseSeedDescriptor(parsedUseBasesMask.dataReads_, seedDescriptor, seedLength, firstPassSeeds);
    }

    flowcell::Layout fc(baseCallsDirectory,
                        flowcell::Layout::Fastq,
                        flowcell::FastqFlowcellData(compressed, fastqQ0),
                        laneNumberMax,
                        flowcellInfo.readNameLength_,
                        std::vector<unsigned>(),
                        parsedUseBasesMask.dataReads_,
                        seedMetadataList, flowcellInfo.flowcellId_);

    std::string regexString(tilesFilter);
    std::replace(regexString.begin(), regexString.end(), ',', '|');
    boost::regex re(regexString);
    BOOST_FOREACH(const unsigned int lane, flowcellInfo.getLanes())
    {
        std::string laneString((boost::format("s_%d") % lane).str());
        if (boost::regex_search(laneString, re))
        {
            fc.addTile(lane, 1);
        }
    }

    return fc;
}