text:
/***************************************************************************//**
* \file cy_i2s.c
* \version 2.30
*
* The source code file for the I2S driver.
*
********************************************************************************
* \copyright
* Copyright 2016-2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/

#include "cy_device.h"

#if (defined (AUDIOSS_I2S_PRESENT) || defined(CY_DOXYGEN))

#include "cy_i2s.h"

/*******************************************************************************
* Function Name: Cy_I2S_Init
****************************************************************************//**
*
* Initializes the I2S module in accordance with a configuration structure.
*
* \pre If the I2S module is initialized previously, the \ref Cy_I2S_DeInit()
* must be called before calling this function.
*
* \param base      The pointer to the I2S instance address.
*
* \param config    The pointer to a configuration structure.
*
* \return error / status code. See \ref cy_en_i2s_status_t.
*
* \funcusage
* \snippet i2s/snippet/main.c snippet_Cy_I2S_Init
*
*******************************************************************************/
cy_en_i2s_status_t Cy_I2S_Init(I2S_Type * base, cy_stc_i2s_config_t const * config)
{
    cy_en_i2s_status_t ret = CY_I2S_BAD_PARAM;

    if((NULL != base) && (NULL != config))
    {
        cy_en_i2s_ws_pw_t wsPulseWidth;
        cy_en_i2s_len_t channelLength;
        uint32_t channels;
        uint32_t clockDiv = (uint32_t)config->clkDiv - 1U;

        CY_ASSERT_L2(CY_I2S_IS_CLK_DIV_VALID(clockDiv));

        REG_I2S_INTR_MASK(base) = 0UL; /* Disable interrupts prior to stopping the operation */
        REG_I2S_CMD(base) = 0UL; /* Stop any communication */
        REG_I2S_TR_CTL(base) = 0UL; /* Disable any DMA triggers */
        REG_I2S_CTL(base) = 0UL; /* Disable TX/RX sub-blocks before clock changing */

        /* The clock setting */

#if (CY_IP_MXAUDIOSS_VERSION>=2)
        REG_I2S_CLOCK_CTL(base) = _VAL2FLD(I2S_CLOCK_CTL_CLOCK_DIV, clockDiv) |
                                  _BOOL2FLD(I2S_CLOCK_CTL_CLOCK_SEL, config->extClk) |
                                  _VAL2FLD(I2S_CLOCK_CTL_CLOCK_DIV, config->mclkDiv) |
                                  _BOOL2FLD(I2S_CLOCK_CTL_CLOCK_SEL, config->mclkEn);
#else
        REG_I2S_CLOCK_CTL(base) = _VAL2FLD(I2S_CLOCK_CTL_CLOCK_DIV, clockDiv) |
                                  _BOOL2FLD(I2S_CLOCK_CTL_CLOCK_SEL, config->extClk);
#endif
        /* The Tx setting */
        if (config->txEnabled)
        {
            CY_ASSERT_L3(CY_I2S_IS_ALIGNMENT_VALID(config->txAlignment));
            CY_ASSERT_L3(CY_I2S_IS_OVHDATA_VALID(config->txOverheadValue));

            if ((CY_I2S_TDM_MODE_A == config->txAlignment) || (CY_I2S_TDM_MODE_B == config->txAlignment))
            {
                channels = (uint32_t)config->txChannels - 1UL;
                wsPulseWidth = config->txWsPulseWidth;
                channelLength = CY_I2S_LEN32;

                CY_ASSERT_L2(CY_I2S_IS_CHANNELS_VALID(channels));
                CY_ASSERT_L3(CY_I2S_IS_WSPULSE_VALID(wsPulseWidth));
                CY_ASSERT_L3(CY_I2S_IS_LEN_VALID(config->txWordLength));
            }
            else
            {
                channels = 1UL;
                wsPulseWidth = CY_I2S_WS_ONE_CHANNEL_LENGTH;
                channelLength = config->txChannelLength;

                CY_ASSERT_L3(CY_I2S_IS_CHAN_WORD_VALID(channelLength, config->txWordLength));
            }

            CY_ASSERT_L2(CY_I2S_IS_TRIG_LEVEL_VALID(config->txFifoTriggerLevel, channels));

            REG_I2S_TX_WATCHDOG(base) = config->txWatchdogValue;

            REG_I2S_TX_CTL(base) = _VAL2FLD(I2S_TX_CTL_I2S_MODE, config->txAlignment) |
                                  _BOOL2FLD(I2S_TX_CTL_B_CLOCK_INV, config->txSdoLatchingTime) |
                                   _VAL2FLD(I2S_TX_CTL_CH_NR, channels) |
                                  _BOOL2FLD(I2S_TX_CTL_MS, config->txMasterMode) |
                                   _VAL2FLD(I2S_TX_CTL_WS_PULSE, wsPulseWidth) |
                                  _BOOL2FLD(I2S_TX_CTL_WD_EN, config->txWatchdogEnable) |
                                  _BOOL2FLD(I2S_TX_CTL_SCKO_POL, config->txSckoInversion) |
                                  _BOOL2FLD(I2S_TX_CTL_SCKI_POL, config->txSckiInversion) |
                                   _VAL2FLD(I2S_TX_CTL_CH_LEN, channelLength) |
                                   _VAL2FLD(I2S_TX_CTL_WORD_LEN, config->txWordLength) |
                                   _VAL2FLD(I2S_TX_CTL_OVHDATA, config->txOverheadValue);
        }

        /* The Rx setting */
        if (config->rxEnabled)
        {
            CY_ASSERT_L3(CY_I2S_IS_ALIGNMENT_VALID(config->rxAlignment));

            if ((CY_I2S_TDM_MODE_A == config->rxAlignment) || (CY_I2S_TDM_MODE_B == config->rxAlignment))
            {
                channels = (uint32_t)config->rxChannels - 1UL;
                wsPulseWidth = config->rxWsPulseWidth;
                channelLength = CY_I2S_LEN32;

                CY_ASSERT_L2(CY_I2S_IS_CHANNELS_VALID(channels));
                CY_ASSERT_L3(CY_I2S_IS_WSPULSE_VALID(wsPulseWidth));
                CY_ASSERT_L3(CY_I2S_IS_LEN_VALID(config->rxWordLength));
            }
            else
            {
                channels = 1UL;
                wsPulseWidth = CY_I2S_WS_ONE_CHANNEL_LENGTH;
                channelLength = config->rxChannelLength;

                CY_ASSERT_L3(CY_I2S_IS_CHAN_WORD_VALID(channelLength, config->rxWordLength));
            }

            CY_ASSERT_L2(CY_I2S_IS_TRIG_LEVEL_VALID(config->rxFifoTriggerLevel, channels));

            REG_I2S_RX_WATCHDOG(base) = config->rxWatchdogValue;

            REG_I2S_RX_CTL(base) = _VAL2FLD(I2S_RX_CTL_I2S_MODE, config->rxAlignment) |
                                  _BOOL2FLD(I2S_RX_CTL_B_CLOCK_INV, config->rxSdiLatchingTime) |
                                   _VAL2FLD(I2S_RX_CTL_CH_NR, channels) |
                                  _BOOL2FLD(I2S_RX_CTL_MS, config->rxMasterMode) |
                                   _VAL2FLD(I2S_RX_CTL_WS_PULSE, wsPulseWidth) |
                                  _BOOL2FLD(I2S_RX_CTL_WD_EN, config->rxWatchdogEnable) |
                                  _BOOL2FLD(I2S_RX_CTL_SCKO_POL, config->rxSckoInversion) |
                                  _BOOL2FLD(I2S_RX_CTL_SCKI_POL, config->rxSckiInversion) |
                                   _VAL2FLD(I2S_RX_CTL_CH_LEN, channelLength) |
                                   _VAL2FLD(I2S_RX_CTL_WORD_LEN, config->rxWordLength) |
                                  _BOOL2FLD(I2S_RX_CTL_BIT_EXTENSION, config->rxSignExtension);
        }

        /* The I2S enable setting */
        if (config->txEnabled)
        {
            REG_I2S_CTL(base) |= I2S_CTL_TX_ENABLED_Msk;
        }

        if (config->rxEnabled)
        {
            REG_I2S_CTL(base) |= I2S_CTL_RX_ENABLED_Msk;
        }

        /* The FIFO setting */
        if (config->txEnabled)
        {
            REG_I2S_TX_FIFO_CTL(base) = _VAL2FLD(I2S_TX_FIFO_CTL_TRIGGER_LEVEL, config->txFifoTriggerLevel);

            REG_I2S_TR_CTL(base) |= _BOOL2FLD(I2S_TR_CTL_TX_REQ_EN, config->txDmaTrigger);
        }

        if (config->rxEnabled)
        {
            REG_I2S_RX_FIFO_CTL(base) = _VAL2FLD(I2S_RX_FIFO_CTL_TRIGGER_LEVEL, config->rxFifoTriggerLevel);

            REG_I2S_TR_CTL(base) |= _BOOL2FLD(I2S_TR_CTL_RX_REQ_EN, config->rxDmaTrigger);
        }

        ret = CY_I2S_SUCCESS;
    }

    return (ret);
}

/*******************************************************************************
* Function Name: Cy_I2S_DeInit
****************************************************************************//**
*
* Uninitializes the I2S module (reverts default register values).
*
* \param base The pointer to the I2S instance address.
*
* \funcusage
* \snippet i2s/snippet/main.c snippet_Cy_I2S_DeInit
*
*******************************************************************************/
void Cy_I2S_DeInit(I2S_Type * base)
{
    REG_I2S_INTR_MASK(base) = 0UL; /* Disable interrupts prior to stopping the operation */
    REG_I2S_CMD(base) = 0UL;
    REG_I2S_TR_CTL(base) = 0UL;
    REG_I2S_TX_FIFO_CTL(base) = 0UL;
    REG_I2S_RX_FIFO_CTL(base) = 0UL;
    REG_I2S_CTL(base) = 0UL;
    REG_I2S_TX_CTL(base) = CY_I2S_TX_CTL_DEFAULT;
    REG_I2S_RX_CTL(base) = CY_I2S_RX_CTL_DEFAULT;
    REG_I2S_TX_WATCHDOG(base) = 0UL;
    REG_I2S_RX_WATCHDOG(base) = 0UL;
    REG_I2S_CLOCK_CTL(base) = 0UL;
}

/*******************************************************************************
* Function Name: Cy_I2S_DeepSleepCallback
****************************************************************************//**
*
* This is a callback function to be used at the application layer to
* manage an I2S operation during the Deep Sleep cycle. It stores the I2S state
* (Tx/Rx enabled/disabled/paused) into the context structure and stops the
* communication before entering into Deep Sleep power mode and restores the I2S
* state after waking up.
*
* \param
* callbackParams - The pointer to the callback parameters structure,
* see \ref cy_stc_syspm_callback_params_t.
*
* \param mode
* Callback mode, see \ref cy_en_syspm_callback_mode_t
*
* \return the SysPm callback status \ref cy_en_syspm_status_t.
*
* \note Use the \ref cy_stc_i2s_context_t data type for definition of the
* *context element of the \ref cy_stc_syspm_callback_params_t structure.
*
* \funcusage
* \snippet i2s/snippet/main.c snippet_Cy_I2S_DeepSleepCallback
*
*******************************************************************************/
cy_en_syspm_status_t Cy_I2S_DeepSleepCallback (cy_stc_syspm_callback_params_t const *callbackParams, cy_en_syspm_callback_mode_t mode)
{
    cy_en_syspm_status_t ret = CY_SYSPM_SUCCESS;
    CY_ASSERT_L1(NULL != callbackParams->context);
    I2S_Type * locBase = (I2S_Type*) callbackParams->base;
    uint32_t * locInterruptMask = (uint32_t*) &(((cy_stc_i2s_context_t*)(callbackParams->context))->interruptMask);
    uint32_t * locState = (uint32_t*) &(((cy_stc_i2s_context_t*)(callbackParams->context))->enableState);

    switch(mode)
    {
        case CY_SYSPM_CHECK_READY:
        case CY_SYSPM_CHECK_FAIL:
            break;

        case CY_SYSPM_BEFORE_TRANSITION:
            *locInterruptMask = Cy_I2S_GetInterruptMask(locBase); /* Store I2S interrupts */
            *locState = Cy_I2S_GetCurrentState(locBase); /* Store I2S state */
            if (0UL != (*locState & I2S_CMD_TX_START_Msk))
            {
                Cy_I2S_DisableTx(locBase); /* Stop TX operation */
            }
            if (0UL != (*locState & I2S_CMD_RX_START_Msk))
            {
                Cy_I2S_DisableRx(locBase); /* Stop RX operation */
            }
            Cy_I2S_SetInterruptMask(locBase, 0UL); /* Disable I2S interrupts */
            /* Unload FIFOs to not lose data (if needed) */
            break;

        case CY_SYSPM_AFTER_TRANSITION:
            if (0UL != (*locState & I2S_CMD_RX_START_Msk))
            {
                Cy_I2S_ClearRxFifo(locBase); /* Clear the RX FIFO */
                Cy_I2S_EnableRx(locBase); /* Start RX operation */
            }
            if (0UL != (*locState & I2S_CMD_TX_START_Msk))
            {
                Cy_I2S_ClearTxFifo(locBase); /* Clear the TX FIFO */
                Cy_I2S_WriteTxData(locBase, 0UL); /* Fill at least one TX frame */
                Cy_I2S_WriteTxData(locBase, 0UL);
                if (0UL != (*locState & I2S_CMD_TX_PAUSE_Msk))
                {
                    Cy_I2S_PauseTx(locBase); /* Restore the TX paused state */
                }
                Cy_I2S_EnableTx(locBase); /* Start TX operation */
            }
            Cy_I2S_ClearInterrupt(locBase, *locInterruptMask); /* Clear possible pending I2S interrupts */
            Cy_I2S_SetInterruptMask(locBase, *locInterruptMask); /* Restore I2S interrupts */
            break;

        default:
            ret = CY_SYSPM_FAIL;
            break;
    }

    return(ret);
}

#endif /* CY_IP_MXAUDIOSS */

/* [] END OF FILE */


text:
package com.amazonaws.services.ec2.model.transform;

import javax.annotation.Generated;

import com.amazonaws.SdkClientException;
import com.amazonaws.Request;
import com.amazonaws.DefaultRequest;
import com.amazonaws.http.HttpMethodName;
import com.amazonaws.services.ec2.model.*;
import com.amazonaws.transform.Marshaller;
import com.amazonaws.util.StringUtils;

/**
 * CopySnapshotRequest Marshaller
 */

@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class CopySnapshotRequestMarshaller implements Marshaller<Request<CopySnapshotRequest>, CopySnapshotRequest> {

    public Request<CopySnapshotRequest> marshall(CopySnapshotRequest copySnapshotRequest) {

        if (copySnapshotRequest == null) {
            throw new SdkClientException("Invalid argument passed to marshall(...)");
        }

        Request<CopySnapshotRequest> request = new DefaultRequest<CopySnapshotRequest>(copySnapshotRequest, "AmazonEC2");
        request.addParameter("Action", "CopySnapshot");
        request.addParameter("Version", "2016-11-15");
        request.setHttpMethod(HttpMethodName.POST);

        if (copySnapshotRequest.getDescription() != null) {
            request.addParameter("Description", StringUtils.fromString(copySnapshotRequest.getDescription()));
        }

        if (copySnapshotRequest.getDestinationRegion() != null) {
            request.addParameter("DestinationRegion", StringUtils.fromString(copySnapshotRequest.getDestinationRegion()));
        }

        if (copySnapshotRequest.getEncrypted() != null) {
            request.addParameter("Encrypted", StringUtils.fromBoolean(copySnapshotRequest.getEncrypted()));
        }

        if (copySnapshotRequest.getKmsKeyId() != null) {
            request.addParameter("KmsKeyId", StringUtils.fromString(copySnapshotRequest.getKmsKeyId()));
        }

        if (copySnapshotRequest.getPresignedUrl() != null) {
            request.addParameter("PresignedUrl", StringUtils.fromString(copySnapshotRequest.getPresignedUrl()));
        }

        if (copySnapshotRequest.getSourceRegion() != null) {
            request.addParameter("SourceRegion", StringUtils.fromString(copySnapshotRequest.getSourceRegion()));
        }

        if (copySnapshotRequest.getSourceSnapshotId() != null) {
            request.addParameter("SourceSnapshotId", StringUtils.fromString(copySnapshotRequest.getSourceSnapshotId()));
        }

        return request;
    }

}

redpajama_set_name: RedPajamaGithub


text:
Rack-pjax [![travis](https://secure.travis-ci.org/eval/rack-pjax.png?branch=master)](https://secure.travis-ci.org/#!/eval/rack-pjax)
========

Rack-pjax is middleware that lets you serve 'chrome-less' pages in respond to [pjax-requests](https://github.com/defunkt/jquery-pjax).

It does this by stripping the generated body; only the title and inner-html of the pjax-container are sent to the client.

While this won't save you any time rendering the page, it gives you more flexibility where and how to define the pjax-container.
Ryan Bates featured [rack-pjax on Railscasts](http://railscasts.com/episodes/294-playing-with-pjax) and explains how this gem compares to [pjax_rails](https://github.com/rails/pjax_rails).

[![railscast](http://railscasts.com/assets/railscasts_logo-7101a7cd0a48292a0c07276981855edb.png)](http://railscasts.com/)

Installation
------------

Check out the [Railscasts' notes](http://railscasts.com/episodes/294-playing-with-pjax) how to integrate rack-pjax in your Rails 3.1 application.

You can find the source from the screencast over [here](https://github.com/ryanb/railscasts-episodes/tree/master/episode-294).

Another sample-app: the original [pjax-demo](http://pjax.herokuapp.com/) but with rack-pjax onboard can be found in the [sample-app](https://github.com/eval/rack-pjax/tree/sample-app) branch.

The more generic installation comes down to:

I. Add the gem to your Gemfile

```ruby
# Gemfile
gem "rack-pjax"
```

II. Include **rack-pjax** as middleware to your application(-stack)

```ruby
# config.ru
require ::File.expand_path('../config/environment',  __FILE__)
use Rack::Pjax
run RackApp::Application
```

III. Install [jquery-pjax](https://github.com/defunkt/jquery-pjax). Make sure to add the 'data-pjax-container'-attribute to the container.

```html
<head>
  ...
  <script src="/javascripts/jquery.js"></script>
  <script src="/javascripts/jquery.pjax.js"></script>
  <script type="text/javascript">
    $(function(){
      $(document).pjax('a', '[data-pjax-container]')
    })
  </script>
  ...
</head>
<body>
  <div data-pjax-container>
    ...
  </div>
</body>
```

(For more see [the docs of jquery-pjax](https://github.com/defunkt/jquery-pjax#usage).)

IV. Fire up your [pushState-enabled browser](http://caniuse.com/#search=pushstate) and enjoy!

Requirements
------------

- Nokogiri

Contributors
------

[The contributors](https://github.com/eval/rack-pjax/graphs/contributors).


text:
namespace LiteDB.Shell.Commands
{
    internal class CollectionMax : BaseCollection, IShellCommand
    {
        public bool IsCommand(StringScanner s)
        {
            return IsCollectionCommand(s, "max");
        }

        public BsonValue Execute(DbEngine engine, StringScanner s)
        {
            var col = ReadCollection(engine, s);
            var index = s.Scan(FieldPattern).Trim();

            return engine.Max(col, index.Length == 0 ? "_id" : index);
        }
    }
}


text:
module.exports = function(RED) {
    function nodeFunction(config) {
        RED.nodes.createNode(this,config);
    }
    RED.nodes.registerType("Looper",nodeFunction);
}


text:
package org.apache.flink.table.calcite

import org.apache.flink.table.`type`.{InternalType, InternalTypes}

import org.junit.{Assert, Test}

class FlinkTypeFactoryTest {

  @Test
  def testInternalToRelType(): Unit = {
    val typeFactory = new FlinkTypeFactory(new FlinkTypeSystem)

    def test(t: InternalType): Unit = {
      Assert.assertEquals(
        t,
        FlinkTypeFactory.toInternalType(
          typeFactory.createTypeFromInternalType(t, isNullable = true))
      )

      Assert.assertEquals(
        t,
        FlinkTypeFactory.toInternalType(
          typeFactory.createTypeFromInternalType(t, isNullable = false))
      )

      // twice for cache.
      Assert.assertEquals(
        t,
        FlinkTypeFactory.toInternalType(
          typeFactory.createTypeFromInternalType(t, isNullable = true))
      )

      Assert.assertEquals(
        t,
        FlinkTypeFactory.toInternalType(
          typeFactory.createTypeFromInternalType(t, isNullable = false))
      )
    }

    test(InternalTypes.BOOLEAN)
    test(InternalTypes.BYTE)
    test(InternalTypes.STRING)
    test(InternalTypes.DOUBLE)
    test(InternalTypes.FLOAT)
    test(InternalTypes.INT)
    test(InternalTypes.LONG)
    test(InternalTypes.SHORT)
    test(InternalTypes.BINARY)
    test(InternalTypes.DATE)
    test(InternalTypes.TIME)
    test(InternalTypes.TIMESTAMP)

    test(InternalTypes.createArrayType(InternalTypes.DOUBLE))
    test(InternalTypes.createMapType(InternalTypes.DOUBLE, InternalTypes.STRING))
    test(InternalTypes.createRowType(InternalTypes.DOUBLE, InternalTypes.STRING))
  }
}


text:
<?php

namespace common\models;

use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\CsTags;

/**
 * CsTagsSearch represents the model behind the search form about `common\models\CsTags`.
 */
class CsTagsSearch extends CsTags
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'entity_id'], 'integer'],
            [['entity', 'lang_code', 'tag', 'orig_name'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = CsTags::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'entity_id' => $this->entity_id,
        ]);

        $query->andFilterWhere(['like', 'entity', $this->entity])
            ->andFilterWhere(['like', 'lang_code', $this->lang_code])
            ->andFilterWhere(['like', 'tag', $this->tag])
            ->andFilterWhere(['like', 'orig_name', $this->orig_name]);

        return $dataProvider;
    }
}


text:
#ifndef __TAG17__
#define __TAG17__

#include <vector>
#include <string>

#include "Packets/User.h"
#include "Packets/Tag17/Subpackets.h"

namespace OpenPGP {
    namespace Packet {

        // 5.12. User Attribute Packet (Tag 17)
        //
        //    The User Attribute packet is a variation of the User ID packet. It
        //    is capable of storing more types of data than the User ID packet,
        //    which is limited to text. Like the User ID packet, a User Attribute
        //    packet may be certified by the key owner ("self-signed") or any other
        //    key owner who cares to certify it. Except as noted, a User Attribute
        //    packet may be used anywhere that a User ID packet may be used.
        //
        //    While User Attribute packets are not a required part of the OpenPGP
        //    standard, implementations SHOULD provide at least enough
        //    compatibility to properly handle a certification signature on the
        //    User Attribute packet. A simple way to do this is by treating the
        //    User Attribute packet as a User ID packet with opaque contents, but
        //    an implementation may use any method desired.
        //
        //    The User Attribute packet is made up of one or more attribute
        //    subpackets. Each subpacket consists of a subpacket header and a
        //    body. The header consists of:
        //
        //      - the subpacket length (1, 2, or 5 octets)
        //
        //      - the subpacket type (1 octet)
        //
        //    and is followed by the subpacket specific data.
        //
        //    The only currently defined subpacket type is 1, signifying an image.
        //    An implementation SHOULD ignore any subpacket of a type that it does
        //    not recognize. Subpacket types 100 through 110 are reserved for
        //    private or experimental use.

        class Tag17 : public User {
            public:
                typedef std::vector <Subpacket::Tag17::Sub::Ptr> Attributes;

            private:
                // only defined subpacket is 1
                Attributes attributes;

                void read_subpacket(const std::string & data, std::string::size_type & pos, std::string::size_type & length);
                void actual_read(const std::string & data, std::string::size_type & pos, const std::string::size_type & length);
                void show_contents(HumanReadable & hr) const;
                std::string actual_raw() const;
                Status actual_valid(const bool check_mpi) const;

            public:
                typedef std::shared_ptr <Packet::Tag17> Ptr;

                Tag17();
                Tag17(const Tag17 & copy);
                Tag17(const std::string & data);
                ~Tag17();

                Attributes get_attributes() const;
                Attributes get_attributes_clone() const;
                void set_attributes(const Attributes & a);

                Tag::Ptr clone() const;
                Tag17 & operator=(const Tag17 & tag17);
        };
    }
}

#endif


text:
curl -sSf https://static.rust-lang.org/rustup.sh | sh
#curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=beta
#curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly


text:
<?php

namespace Unit\lib\Manipulator;

use Chris\Composer\AutoregisterClassmapPlugin\Parser\RegisterFileParser;
use Phake;
use Phake_IMock;
use PHPUnit_Framework_TestCase;
use Symfony\Component\Finder\SplFileInfo;

class RegisterFileParserTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var string PATH_TO_REGISTER_TEST
     */
    const PATH_TO_REGISTER_TEST = './tests/Resources/.module.test.yml';

    /**
     * @var RegisterFileParser
     */
    protected $parser;

    /**
     * @var SplFileInfo|Phake_IMock
     */
    protected $fileInfo;

    /**
     * {@inheritdoc}
     */
    public function setUp()
    {
        $this->fileInfo = Phake::mock(SplFileInfo::class);
        $this->parser   = new RegisterFileParser();
    }

    public function testExtractRegisterInformation()
    {
        Phake::when($this->fileInfo)->getContents()->thenReturn($this->getRegisterInformation());
        Phake::when($this->fileInfo)->getPathInfo()->thenReturn($this->fileInfo);
        Phake::when($this->fileInfo)->getRealPath()->thenReturn('/path/to/module');

        $this->parser->extractRegisterInformation($this->fileInfo);

        Phake::verify($this->fileInfo)->getContents();
        Phake::verify($this->fileInfo)->getPathInfo();
        Phake::verify($this->fileInfo)->getRealPath();
    }

    public function getRegisterInformation()
    {
        return file_get_contents(static::PATH_TO_REGISTER_TEST);
    }
}


text:
package org.apache.camel.component.dozer;

import java.io.InputStream;

import org.apache.camel.CamelContext;
import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.spring.junit5.CamelSpringTest;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

import static org.junit.jupiter.api.Assertions.assertEquals;

@CamelSpringTest
@ContextConfiguration
public class XmlToJsonTest {

    private static final String ABC_ORDER_PATH = "org/apache/camel/component/dozer/abc-order.xml";
    private static final String XYZ_ORDER_PATH = "org/apache/camel/component/dozer/xyz-order.json";

    @EndpointInject("mock:result")
    private MockEndpoint resultEndpoint;

    @Produce("direct:start")
    private ProducerTemplate startEndpoint;

    @Autowired
    private CamelContext camelContext;

    @AfterEach
    public void tearDown() {
        resultEndpoint.reset();
    }

    @Test
    void testXmlToJson() throws Exception {
        resultEndpoint.expectedMessageCount(1);
        startEndpoint.sendBody(getResourceAsString(ABC_ORDER_PATH));
        // check results
        resultEndpoint.assertIsSatisfied();
        String result = resultEndpoint.getExchanges().get(0).getIn().getBody(String.class);
        assertEquals(getResourceAsString(XYZ_ORDER_PATH), result);
    }

    @Test
    void testMultipleSends() throws Exception {
        resultEndpoint.expectedMessageCount(2);
        startEndpoint.sendBody(getResourceAsString(ABC_ORDER_PATH));
        startEndpoint.sendBody(getResourceAsString(ABC_ORDER_PATH));
        // check results
        resultEndpoint.assertIsSatisfied();
        String result1 = resultEndpoint.getExchanges().get(0).getIn().getBody(String.class);
        String result2 = resultEndpoint.getExchanges().get(1).getIn().getBody(String.class);
        assertEquals(getResourceAsString(XYZ_ORDER_PATH), result1);
        assertEquals(getResourceAsString(XYZ_ORDER_PATH), result2);
    }

    private String getResourceAsString(String resourcePath) {
        InputStream is = getClass().getClassLoader().getResourceAsStream(resourcePath);
        return camelContext.getTypeConverter().convertTo(String.class, is);
    }
}


text:
package com.google.template.soy.jbcsrc;

import static com.google.template.soy.jbcsrc.BytecodeUtils.SOY_RECORD_TYPE;
import static com.google.template.soy.jbcsrc.BytecodeUtils.defineDefaultConstructor;
import static com.google.template.soy.jbcsrc.LocalVariable.createLocal;
import static com.google.template.soy.jbcsrc.LocalVariable.createThisVar;
import static com.google.template.soy.jbcsrc.StandardNames.FACTORY_CLASS;

import com.google.template.soy.data.SoyRecord;
import com.google.template.soy.jbcsrc.shared.CompiledTemplate;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.commons.GeneratorAdapter;
import org.objectweb.asm.commons.Method;

/**
 * Generates {@link com.google.template.soy.jbcsrc.shared.CompiledTemplate.Factory} implementations.
 *
 *
Each factory is incredibly simple, essentially we are generating this class:
{@code
 *   public final class FooFactory implements CompiledTemplate.Factory {
 *     public CompiledTemplate create(SoyRecord params) {
 *       return new Foo(params);
 *     }
 *   }}

 *
 *
Where the only thing that differs is the name of the template being constructed.
 */
final class TemplateFactoryCompiler {
  private static final TypeInfo FACTORY_TYPE = TypeInfo.create(CompiledTemplate.Factory.class);

  private static final int FACTORY_ACCESS = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL;

  private static final Method CREATE_METHOD;
  static {
    try {
      CREATE_METHOD = Method.getMethod(
          CompiledTemplate.Factory.class.getDeclaredMethod(
              "create", SoyRecord.class, SoyRecord.class));
    } catch (NoSuchMethodException | SecurityException e) {
      throw new AssertionError(e);
    }
  }

  private final CompiledTemplateMetadata template;
  private final InnerClasses innerClasses;

  TemplateFactoryCompiler(CompiledTemplateMetadata currentClass, InnerClasses innerClasses) {
    this.template = currentClass;
    this.innerClasses = innerClasses;
  }

  /** Compiles the factory. */
  void compile() {
    TypeInfo factoryType = innerClasses.registerInnerClass(FACTORY_CLASS, FACTORY_ACCESS);
    SoyClassWriter cw =
        SoyClassWriter.builder(factoryType)
            .implementing(FACTORY_TYPE)
            .setAccess(FACTORY_ACCESS)
            .sourceFileName(template.node().getSourceLocation().getFileName())
            .build();
    innerClasses.registerAsInnerClass(cw, factoryType);

    generateStaticInitializer(cw);
    defineDefaultConstructor(cw, factoryType);
    generateCreateMethod(cw, factoryType);
    cw.visitEnd();
    innerClasses.add(cw.toClassData());
  }

  /**
   * Generates a static initializer that references the CompiledTemplate class to force eager
   * classloading (and thus verification errors). For example,
{@code
   *   static {
   *     Class<?> clz = GeneratedTemplateClass.class;
   *   }}

   *
   *
TODO(lukes): this is useful for now since it will trigger verification errors during
   * compilation (since we load all factories). But we should consider deleting it when the compiler
   * is more mature since it is likely that servers ship dead templates and there is no point
   * loading them.
   */
  private void generateStaticInitializer(ClassVisitor cv) {
    if (Flags.DEBUG) {
      GeneratorAdapter ga =
          new GeneratorAdapter(
              Opcodes.ACC_STATIC,
              BytecodeUtils.CLASS_INIT,
              null /* no generic signature */,
              null /* no checked exceptions */,
              cv);
      ga.visitCode();
      ga.push(template.typeInfo().type());
      ga.visitVarInsn(Opcodes.ASTORE, 0);
      ga.returnValue();
      ga.endMethod();
    }
  }

  /**
   * Writes the {@link CompiledTemplate.Factory#create} method, which directly delegates to the
   * constructor of the {@link #template}.
   */
  private void generateCreateMethod(ClassVisitor cv, TypeInfo factoryType) {
    final Label start = new Label();
    final Label end = new Label();
    final LocalVariable thisVar = createThisVar(factoryType, start, end);
    final LocalVariable paramsVar = createLocal("params", 1, SOY_RECORD_TYPE, start, end);
    final LocalVariable ijVar = createLocal("ij", 2, SOY_RECORD_TYPE, start, end);
    final Statement returnTemplate =
        Statement.returnExpression(template.constructor().construct(paramsVar, ijVar));
    new Statement() {
      @Override void doGen(CodeBuilder ga) {
        ga.mark(start);
        returnTemplate.gen(ga);
        ga.mark(end);
        thisVar.tableEntry(ga);
        paramsVar.tableEntry(ga);
        ijVar.tableEntry(ga);
      }
    }.writeMethod(Opcodes.ACC_PUBLIC, CREATE_METHOD, cv);
  }
}


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.fdmgroup</groupId>
	<artifactId>OODWeek2</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.10</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-all</artifactId>
			<version>1.9.5</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.3</version>
				<configuration>
					<target>1.6</target>
					<source>1.6</source>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>


text:
module Azure::ServiceFabric::V6_5_0_36
  module Models
    #
    # Defines values for DiagnosticsSinkKind
    #
    module DiagnosticsSinkKind
      Invalid = "Invalid"
      AzureInternalMonitoringPipeline = "AzureInternalMonitoringPipeline"
    end
  end
end


text:
Design a logger system that receives a stream of messages along with their timestamps. Each unique message should only be printed _at most every 10 seconds_ (i.e. a message printed at timestamp `t` will prevent other identical messages from being printed until timestamp `t + 10`).

All messages will come in chronological order. Several messages may arrive at the same timestamp.

Implement the `Logger` class:

`Logger()` Initializes the logger object.
`bool shouldPrintMessage(int timestamp, string message)` Returns `true` if the `message` should be printed in the given `timestamp`, otherwise returns `false`.

### Example:

```
Input
["Logger", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage", "shouldPrintMessage"]
[[], [1, "foo"], [2, "bar"], [3, "foo"], [8, "bar"], [10, "foo"], [11, "foo"]]
Output
[null, true, true, false, false, false, true]

Explanation
Logger logger = new Logger();
logger.shouldPrintMessage(1, "foo");  // return true, next allowed timestamp for "foo" is 1 + 10 = 11
logger.shouldPrintMessage(2, "bar");  // return true, next allowed timestamp for "bar" is 2 + 10 = 12
logger.shouldPrintMessage(3, "foo");  // 3 < 11, return false
logger.shouldPrintMessage(8, "bar");  // 8 < 12, return false
logger.shouldPrintMessage(10, "foo"); // 10 < 11, return false
logger.shouldPrintMessage(11, "foo"); // 11 >= 11, return true, next allowed timestamp for "foo" is 11 + 10 = 21
```

### Constraints:

- `0 <= timestamp <= 10^9`
- Every `timestamp` will be passed in non-decreasing order (chronological order).
- `1 <= message.length <= 30`
- At most `10^4` calls will be made to `shouldPrintMessage`.

## Solution

### O(1) in time, but O(m) in space

Store the threshold which is the last timestamp + 10

- If new timestamp less than the threshold: false
- Else update the threshold using new timestamp

### Optimize the space

A fixed hashtable wastes a lot of space as time goes by. An optimization is to deprecate the hashtable every 10 seconds.

### Other apporaches

One simple approach putting space into consideration is to keep messages within 10 seconds in a queue and discard the stale ones, but if the load is heavy, the size of queue could still big and also it will be O(m) worst time to clean up queue.

Another balanced approach is to use bucket to store messages by mod 10, and discard old ones.

#GOOGL

#Hash Table #Design


text:
angular.module("myApp", ["downgularJS"])

.config( [
    '$compileProvider', '$httpProvider', 'downgularFileToolsProvider',
    function( $compileProvider, $httpProvider, downgularFileToolsProvider ) {
        //allow images to be loaded from filesystem
        $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|file|blob|filesystem):|data:image\//);

        /* configure storage details*/
        downgularFileToolsProvider.usePersistentMemory(true);
        downgularFileToolsProvider.setStorageQuota(30*1024*1024);
    }
])

  .controller("main", ['$scope', 'downgularQueue', function($scope, downgularQueue) {

      var imagesQueue;
      var imageURLs = [
          "http://localhost:1337/www.hdwallpapers.in/walls/sleepy_kitten-wide.jpg",
          "http://localhost:1337/kpbs.media.clients.ellingtoncms.com/img/news/tease/2014/08/20/Cute_grey_kitten.jpg",
          "http://localhost:1337/upload.wikimedia.org/wikipedia/commons/a/a5/Red_Kitten_01.jpg",
          "http://localhost:1337/www.androscogginanimalhospital.com/blog/wp-content/uploads/2013/12/kitten-photo.jpg",
          "http://localhost:1337/upload.wikimedia.org/wikipedia/commons/d/d3/Little_kitten.jpg",
          "http://localhost:1337/www.sfgov2.org/ftp/uploadedimages/acc/Adoption_Center/Foster%20Kitten%2012007.jpg",
          "http://localhost:1337/upload.wikimedia.org/wikipedia/commons/b/bd/Golden_tabby_and_white_kitten_n01.jpg",
          "http://localhost:1337/www.hdwallpaperscool.com/wp-content/uploads/2015/02/kitten-wool-ball-high-definition-wallpaper-for-desktop-background.jpg",
          "http://localhost:1337/miriadna.com/desctopwalls/images/max/Grey-kitten.jpg",
          "http://localhost:1337/img1.wikia.nocookie.net/__cb20140227161247/creepypasta/images/f/f0/Cats-and-kittens-wallpapers-hdkitten-cat-big-cat-baby-kitten-sleep-2560x1024px-hd-wallpaper--cat-umizfbaa.jpg"
                      ];
      $scope.view = {};

      $scope.view.images = [];
      $scope.view.downloadsStarted = false;

      var updateViewImages = function(fileDownload){
        $scope.view.images.push(fileDownload.fileUrl);
        $scope.$apply();
      }

      $scope.startStop = function(){
        $scope.view.downloadsStarted = !$scope.view.downloadsStarted;
        if($scope.view.downloadsStarted)
          imagesQueue.startDownloading();
        else
          imagesQueue.stopDownloading();
      }

      //add images to download
      $scope.init = function(){
        for(var i=0; i < imageURLs.length; i++){
          imagesQueue.addFileDownload({'imageId': i}, imageURLs[i], "");
        }
      };

      $scope.save = function(){
        imagesQueue.saveFileDownloads();
      }

      $scope.retrieve = function(){
        imagesQueue.loadFileDownloads();
      }

      angular.element(document).ready(function (){
        imagesQueue = downgularQueue.build('images1', 'tempDir1', updateViewImages);

        //set pending downloads from local storage
        imagesQueue.loadFileDownloads();

      });

}]);


text:
        <div class="collapsible-header" style="border: none; background-color: <?php echo $warna_ketiga ?>; color: white; font-weight: 500">
            Berita terbaru

                Kalender TA 2015/2016

                Pembagian dosen RMK masing-masing Lab

                Kalender TA 2015/2016

                Kalender TA 2015/2016


text:
<?php
        global $wpdb;

        if (isset($_POST["school-onbehalf"]))
        {
                $school_ID=$_POST["school-onbehalf"];

                echo "
School chooses available dates
";

        ?>

                <form action="" method="POST">
                        <input type="hidden" name="school_id" value="<?php echo $school_ID ?>">

                                    Date	Start Time	End Time	Remarks

                        <?php

                        $cnt = 1;

                        echo "
";
                        echo "<input type=\"date\" name=\"date[]\">	";
                        echo "<input type=\"time\" name=\"start_time[]\">	";
                        echo "<input type=\"time\" name=\"end_time[]\">	";
                        echo "<input type=\"text\" name=\"remarks[]\">	";
                        echo "
\n";

                        ?>

                        <input type="button" value="Add Row" onclick="addRow('school-timeslots-table')" >

                        <input type="submit" name="submitschooltime" value="Submit" />
                </form>

        <?php
        }
        ?>

<?php
        global $wpdb;

        if (isset($_POST["submitschooltime"]))
        {

                foreach ( $_POST["date"] as $key => $value )
                {
                        if (strlen($_POST["date"][$key]) > 0)
                        {
                                $wpdb->query( $wpdb->prepare(
                                "
                                INSERT INTO school_time_slots
                                ( school_id, date, start_time, end_time, remarks, created_at, updated_at )
                                VALUES ( %s, %s, %s, %s, %s, now(), now() )
                                ",
                                $_POST["school_id"],
                                $_POST["date"][$key],
                                $_POST["start_time"][$key],
                                $_POST["end_time"][$key],
                                $_POST["remarks"][$key] ) );
                        }
                }

                echo "
School time slots inserted successfully
";

        }

?>


text:
package com.jmolsmobile.landscapevideocapture.camera;

import android.annotation.TargetApi;
import android.graphics.ImageFormat;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.media.CamcorderProfile;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.view.SurfaceHolder;

import com.jmolsmobile.landscapevideocapture.CLog;
import com.jmolsmobile.landscapevideocapture.camera.OpenCameraException.OpenType;

import java.io.IOException;
import java.util.List;

@SuppressWarnings("deprecation")
public class CameraWrapper {

    private final int mDisplayRotation;
    private NativeCamera mNativeCamera = null;

    public CameraWrapper(NativeCamera nativeCamera, int displayRotation) {
        mNativeCamera = nativeCamera;
        mDisplayRotation = displayRotation;
    }

    public Camera getCamera() {
        return mNativeCamera.getNativeCamera();
    }

    public void openCamera(boolean useFrontFacingCamera) throws OpenCameraException {
        try {
            mNativeCamera.openNativeCamera(useFrontFacingCamera);
        } catch (final RuntimeException e) {
            e.printStackTrace();
            throw new OpenCameraException(OpenType.INUSE);
        }

        if (mNativeCamera.getNativeCamera() == null)
            throw new OpenCameraException(OpenType.NOCAMERA);
    }

    public void prepareCameraForRecording() throws PrepareCameraException {
        try {
            mNativeCamera.unlockNativeCamera();
        } catch (final RuntimeException e) {
            e.printStackTrace();
            throw new PrepareCameraException();
        }
    }

    public void releaseCamera() {
        if (getCamera() == null) return;
        mNativeCamera.releaseNativeCamera();
    }

    public void startPreview(final SurfaceHolder holder) throws IOException {
        mNativeCamera.setNativePreviewDisplay(holder);
        mNativeCamera.startNativePreview();
    }

    public void stopPreview() throws Exception {
        mNativeCamera.stopNativePreview();
        mNativeCamera.clearNativePreviewCallback();
    }

    public RecordingSize getSupportedRecordingSize(int width, int height) {
        CameraSize recordingSize = getOptimalSize(getSupportedVideoSizes(VERSION.SDK_INT), width, height);
        if (recordingSize == null) {
            CLog.e(CLog.CAMERA, "Failed to find supported recording size - falling back to requested: " + width + "x" + height);
            return new RecordingSize(width, height);
        }
        CLog.d(CLog.CAMERA, "Recording size: " + recordingSize.getWidth() + "x" + recordingSize.getHeight());
        return new RecordingSize(recordingSize.getWidth(), recordingSize.getHeight());
    }

    public CamcorderProfile getBaseRecordingProfile() {
        CamcorderProfile returnProfile;
        if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB) {
            returnProfile = getDefaultRecordingProfile();
        } else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_720P)) {
            returnProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_720P);
        } else if (CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_480P)) {
            returnProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
        } else {
            returnProfile = getDefaultRecordingProfile();
        }
        return returnProfile;
    }

    private CamcorderProfile getDefaultRecordingProfile() {
        CamcorderProfile highProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
        if (highProfile != null) {
            return highProfile;
        }
        CamcorderProfile lowProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_LOW);
        if (lowProfile != null) {
            return lowProfile;
        }
        throw new RuntimeException("No quality level found");
    }

    public void configureForPreview(int viewWidth, int viewHeight) {
        final Parameters params = mNativeCamera.getNativeCameraParameters();
        final CameraSize previewSize = getOptimalSize(params.getSupportedPreviewSizes(), viewWidth, viewHeight);

        params.setPreviewSize(previewSize.getWidth(), previewSize.getHeight());
        params.setPreviewFormat(ImageFormat.NV21);
        mNativeCamera.updateNativeCameraParameters(params);
        mNativeCamera.setDisplayOrientation(getRotationCorrection());
        CLog.d(CLog.CAMERA, "Preview size: " + previewSize.getWidth() + "x" + previewSize.getHeight());
    }

    public void enableAutoFocus() {
        final Parameters params = mNativeCamera.getNativeCameraParameters();
        params.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
        mNativeCamera.updateNativeCameraParameters(params);
    }

    public int getRotationCorrection() {
        int displayRotation = mDisplayRotation * 90;
        if (mNativeCamera.isFrontFacingCamera()) {
            int mirroredRotation = (mNativeCamera.getCameraOrientation() + displayRotation) % 360;
            return (360 - mirroredRotation) % 360;
        } else {
            return (mNativeCamera.getCameraOrientation() - displayRotation + 360) % 360;
        }
    }

    @TargetApi(VERSION_CODES.HONEYCOMB)
    protected List<Size> getSupportedVideoSizes(int currentSdkInt) {
        Parameters params = mNativeCamera.getNativeCameraParameters();

        List<Size> supportedVideoSizes;
        if (currentSdkInt < Build.VERSION_CODES.HONEYCOMB) {
            CLog.e(CLog.CAMERA, "Using supportedPreviewSizes iso supportedVideoSizes due to API restriction");
            supportedVideoSizes = params.getSupportedPreviewSizes();
        } else if (params.getSupportedVideoSizes() == null) {
            CLog.e(CLog.CAMERA, "Using supportedPreviewSizes because supportedVideoSizes is null");
            supportedVideoSizes = params.getSupportedPreviewSizes();
        } else {
            supportedVideoSizes = params.getSupportedVideoSizes();
        }

        return supportedVideoSizes;
    }

    /**
     * Copyright (C) 2013 The Android Open Source Project
     *

     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *

     * http://www.apache.org/licenses/LICENSE-2.0
     *

     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    public CameraSize getOptimalSize(List<Camera.Size> sizes, int w, int h) {
        // Use a very small tolerance because we want an exact match.
        final double ASPECT_TOLERANCE = 0.1;
        final double targetRatio = (double) w / h;
        if (sizes == null) return null;

        Camera.Size optimalSize = null;

        // Start with max value and refine as we iterate over available preview sizes. This is the
        // minimum difference between view and camera height.
        double minDiff = Double.MAX_VALUE;

        // Target view height
        final int targetHeight = h;

        // Try to find a preview size that matches aspect ratio and the target view size.
        // Iterate over all available sizes and pick the largest size that can fit in the view and
        // still maintain the aspect ratio.
        for (final Camera.Size size : sizes) {
            final double ratio = (double) size.width / size.height;
            if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) {
                continue;
            }
            if (Math.abs(size.height - targetHeight) < minDiff) {
                optimalSize = size;
                minDiff = Math.abs(size.height - targetHeight);
            }
        }

        // Cannot find preview size that matches the aspect ratio, ignore the requirement
        if (optimalSize == null) {
            minDiff = Double.MAX_VALUE;
            for (final Camera.Size size : sizes) {
                if (Math.abs(size.height - targetHeight) < minDiff) {
                    optimalSize = size;
                    minDiff = Math.abs(size.height - targetHeight);
                }
            }
        }
        return new CameraSize(optimalSize.width, optimalSize.height);
    }
}


text:
<?xml version="1.0"?>
<tool id="novoplasty" name="NOVOplasty" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="18.01">
    <description>de novo assembler for short circular genomes</description>
    <macros>
        <token name="@TOOL_VERSION@">4.2</token>
        <token name="@VERSION_SUFFIX@">1</token>
        <xml name="content" token_min="" token_max="">
            <param name="genome_range_min" type="text" value="@MIN@" label="Set lower limit for the expected genome size range" help="(Genome Range)"/>
            <param name="genome_range_max" type="text" value="@MAX@" label="Set upper limit for the expected genome size range" help="(Genome Range)"/>
        </xml>
    </macros>
    <requirements>
        <requirement type="package" version="@TOOL_VERSION@">novoplasty</requirement>
    </requirements>
    <version_command><![CDATA[NOVOPlasty.pl 2>&1 | grep 'Version' | awk -F' ' '{print $2}']]></version_command>
    <command detect_errors="exit_code"><![CDATA[
## initialize
## samples require extension .fasta or .fasta.gz
#if $reads_cond.reads_sel == 'combined'
    ln -s '$reads_cond.combined_reads' 'combined.${reads_cond.combined_reads.datatype.file_ext}' &&
#else if $reads_cond.reads_sel == 'separate'
    ln -s '$reads_cond.forward_reads' 'forward.${reads_cond.forward_reads.datatype.file_ext}' &&
    ln -s '$reads_cond.reverse_reads' 'reverse.${reads_cond.reverse_reads.datatype.file_ext}' &&
#end if

## run
NOVOPlasty.pl -c '$config'

## postprocessing
&& cp '$config' 'config.txt'
        ]]></command>
    <configfiles>
        <configfile name="config"><![CDATA[
Project:
-----------------------
Project name          = result
Type                  = ${assembly_options.type_cond.type_sel}
Genome Range          = ${assembly_options.type_cond.genome_range_min}-${assembly_options.type_cond.genome_range_max}
K-mer                 = ${assembly_options.kmer}
Max memory            =
Extended log          = 1
Save assembled reads  = ${optional.save_assembled_reads}
Seed Input            = ${seed_input}
Extend seed directly  = ${assembly_options.extend_seed_directly}
Reference sequence    = #if $reference_cond.use_reference == 'true' and $reference_cond.reference then $reference_cond.reference else ''#
Variance detection    = #if $reference_cond.use_reference == 'true' then $reference_cond.variance_detection else ''#
Chloroplast sequence  = #if $assembly_options.type_cond.type_sel == 'mito_plant' and $assembly_options.type_cond.chloroplast_sequence then $assembly_options.type_cond.chloroplast_sequence else ''#

Dataset 1:
-----------------------
Read Length           = ${read_options.read_length}
Insert size           = ${read_options.insert_size}
Platform              = ${read_options.platform}
Single/Paired         = PE
Combined reads        = #if $reads_cond.reads_sel == 'combined' then 'combined.'+$reads_cond.combined_reads.datatype.file_ext else ''#
Forward reads         = #if $reads_cond.reads_sel == 'separate' then 'forward.'+$reads_cond.forward_reads.datatype.file_ext else ''#
Reverse reads         = #if $reads_cond.reads_sel == 'separate' then 'reverse.'+$reads_cond.reverse_reads.datatype.file_ext else ''#

Heteroplasmy:
-----------------------
MAF                   = #if $reference_cond.use_reference == 'true' and $reference_cond.heteroplasmy_cond.detect_heteroplasmy == 'true' then $reference_cond.heteroplasmy_cond.maf else ''#
HP exclude list       = ## option not available
PCR-free              = #if $reference_cond.use_reference == 'true' and $reference_cond.heteroplasmy_cond.detect_heteroplasmy == 'true' then $reference_cond.heteroplasmy_cond.pcr_free else ''#

Optional:
-----------------------
Insert size auto      = ${optional.insert_size_auto}
Insert Range          = ${optional.insert_range}
Insert Range strict   = ${optional.insert_range_strict}
Use Quality Scores    = ${optional.use_quality_scores}
        ]]></configfile>
    </configfiles>
    <inputs>

        <conditional name="reads_cond">
            <param name="reads_sel" type="select" label="Select read file type" help="Currently only paired-end reads are supported">
                <option value="combined">Combined reads</option>
                <option value="separate" selected="true">Separate reads</option>
            </param>
            <when value="combined">
                <param name="combined_reads" type="data" format="fasta,fasta.gz" label="Select file with combined reads" help="(Combined reads)"/>
            </when>
            <when value="separate">
                <param name="forward_reads" type="data" format="fasta,fasta.gz" label="Select file with forward reads" help="(Forward reads)"/>
                <param name="reverse_reads" type="data" format="fasta,fasta.gz" label="Select file with reverse reads" help="(Reverse reads)"/>
            </when>
        </conditional>

        <param name="seed_input" type="data" format="fasta" label="Select file with seed sequence" help="(Seed Input)"/>
        <conditional name="reference_cond">
            <param name="use_reference" type="select" label="Use reference genome" help="If a reference is available, you can select the fasta file.">
                <option value="true">Yes</option>
                <option value="false" selected="true">No</option>
            </param>
            <when value="true">
                <param name="reference" type="data" format="fasta,fasta.gz" optional="true" label="Select reference file" help="The assembly will still be de novo, but references of the same genus can be used as a guide to resolve duplicated regions in the plant mitochondria or the inverted repeat in the chloroplast. References from different genus haven't beeen tested yet."/>
                <conditional name="heteroplasmy_cond">
                    <param name="detect_heteroplasmy" type="select" label="Detect heteroplasmy" help="If you want to detect heteroplasmy, first assemble the genome without this option. Then give the resulting sequence as a reference and as a seed input.">
                        <option value="true">Yes</option>
                        <option value="false" selected="true">No</option>
                    </param>
                    <when value="true">
                        <param name="maf" type="float" value="0.007" min="0.007" max="0.49" label="Set minimum minor allele frequency" help="If you want to detect heteroplasmy, first assemble the genome without this option. Then give the resulting sequence as a reference and as a seed input."/>
                        <param name="pcr_free" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="PCR-free" help="If you have a PCR-free library select yes" />
                    </when>
                    <when value="false"/>
                </conditional>
                <param name="variance_detection" type="boolean" truevalue="yes" falsevalue="no" label="Variance detection" help="It will create a vcf file with all the variances compared to the given reference genome." />
            </when>
            <when value="false"/>
        </conditional>

            <param name="platform" type="select" label="Platform">
                <option value="illumina" selected="true">Illumina</option>
                <option value="ion">Ion Torrent</option>
            </param>
            <param name="read_length" type="integer" value="151" label="Set read length" help="(Read Length)"/>
            <param name="insert_size" type="integer" value="300" label="Set total insert size of your paired end reads" help="It doesn't have to be accurate but should be close enough. (Insert size)"/>

            <conditional name="type_cond">
                <param name="type_sel" type="select" label="Assembly type" help="Chloroplast assembly (chloro), mitochondrial assembly (mito) and mitochondrial assembly in plants (mito_plant).">
                    <option value="chloro" selected="true">Chloroplast assembly</option>
                    <option value="mito">Mitochondrial assembly</option>
                    <option value="mito_plant">Mitochondrial assembly in plants</option>
                </param>
                <when value="chloro">
                    <expand macro="content" min="120000" max="200000"/>
                </when>
                <when value="mito">
                    <expand macro="content" min="12000" max="20000"/>
                </when>
                <when value="mito_plant">
                    <expand macro="content" min="12000" max="20000"/>
                    <param name="chloroplast_sequence" type="data" format="fasta,fasta.gz" optional="true" label="Select chloroplast sequence" help="Chloroplast needs to be assembled before mitochondria. (Chloroplast sequence)"/>
                </when>
            </conditional>
            <param name="extend_seed_directly" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="Extend seeds instead of finding matching reads" help="Only use this when your seed originates from the same sample and there are no possible mismatches. (Extend seed directly)"/>
            <param name="kmer" type="integer" value="39" min="1" label="Set length of overlap between matching reads" help="If reads are shorter then 90 bp or you have low coverage data, this value should be decreased down to 23. For reads longer then 101 bp, this value can be increased, but this is not necessary. (kmer)"/>

            <param name="insert_size_auto" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="Finetune your insert size automatically?" help="(Insert size auto)"/>
            <param name="insert_range" type="float" min="0" value="1.6" label="Insert range" help="This variation on the insert size, could lower it when the coverage is very high or raise it when the coverage is too low [use default in the first run]." />
            <param name="insert_range_strict" type="float" min="0" value="1.2" label="Insert range strict" help="Strict variation to resolve repetitive regions [use default in the first run]." />
            <param name="use_quality_scores" type="boolean" truevalue="yes" falsevalue="no" label="Take quality scores into account?" help="Only use this when reads have low quality, like with the 300 bp reads of Illumina. (Use Quality Scores)"/>
            <param name="save_assembled_reads" type="boolean" truevalue="yes" falsevalue="no" checked="false" label="Retain original IDs when saving assemled reads?" help="All the reads used for the assembly will be stored in seperate files. (Save assembled reads)"/>

        <param name="out" type="select" multiple="true" optional="true" display="checkboxes" label="Additional output files">
            <option value="config">Config file</option>
            <option value="extended_log">Extended log</option>
            <option value="log">Log</option>
            <option value="cont_tmp">Contigs temp</option>
        </param>
    </inputs>
    <outputs>

        <data name="out_c" format="fasta" from_work_dir="Contigs_1_result.fasta" label="${tool.name} on ${on_string}: Contigs"/>
        <data name="out_ct" format="txt" from_work_dir="contigs_tmp_result.txt" label="${tool.name} on ${on_string}: Contigs Tmp">
            <filter>out and 'cont_tmp' in out</filter>
        </data>
        <data name="out_mc" format="txt" from_work_dir="Merged_contigs_result.txt" label="${tool.name} on ${on_string}: Merged Contigs"/>
        <data name="out_cc_o1" format="fasta" from_work_dir="Option_1_result.fasta" label="${tool.name} on ${on_string}: Assembly option 1"/>
        <data name="out_cc_o2" format="fasta" from_work_dir="Option_2_result.fasta" label="${tool.name} on ${on_string}: Assembly option 2"/>
        <data name="out_ar1" format="fasta" from_work_dir="Assembled_reads_result_R1.fasta" label="${tool.name} on ${on_string}: Assembled reads R1">
            <filter>optional['save_assembled_reads'] == True</filter>
        </data>
        <data name="out_ar2" format="fasta" from_work_dir="Assembled_reads_result_R2.fasta" label="${tool.name} on ${on_string}: Assembled reads R2">
            <filter>optional['save_assembled_reads'] == True</filter>
        </data>
        <data name="out_ua" format="fasta" from_work_dir="Uncircularized_assemblies_1_result.fasta" label="${tool.name} on ${on_string}: Uncircularized assemblies"/>
        <data name="out_ca" format="fasta" from_work_dir="Circularized_assembly_1_result.fasta" label="${tool.name} on ${on_string}: Circularized assembly"/>

        <data name="out_v" format="vcf" from_work_dir="Variance_result.vcf" label="${tool.name} on ${on_string}: Variance">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['variance_detection'] == True</filter>
        </data>

        <data name="out_h" format="vcf" from_work_dir="Heteroplasmy_result.vcf" label="${tool.name} on ${on_string}: Heteroplasmy">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_ha" format="fasta" from_work_dir="Heteroplasmy_assemblies_result.fasta" label="${tool.name} on ${on_string}: Heteroplasmy assemblies">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_lth" format="tabular" from_work_dir="Linkage_table_heteroplasmy_result.txt" label="${tool.name} on ${on_string}: Linkage table heteroplasmy">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_pn" format="vcf" from_work_dir="Possible_NUMTs_result.vcf" label="${tool.name} on ${on_string}: Possible NUMTs">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_pna" format="fasta" from_work_dir="Possible_NUMTs_assemblies_result.fasta" label="${tool.name} on ${on_string}: Possible_NUMTs_assemblies_project.fasta">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_ltn" format="tabular" from_work_dir="Linkage_table_NUMTs_result.txt" label="${tool.name} on ${on_string}: Linkage table NUMTs">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_cm" format="txt" from_work_dir="Circos_mutations_result.txt" label="${tool.name} on ${on_string}: Circos mutations">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>
        <data name="out_cl" format="txt" from_work_dir="Circos_links_result.txt" label="${tool.name} on ${on_string}: Circos links">
            <filter>reference_cond['use_reference'] == 'true' and reference_cond['heteroplasmy_cond']['detect_heteroplasmy'] == 'true'</filter>
        </data>

        <data name="out_l" format="txt" from_work_dir="log_result.txt" label="${tool.name} on ${on_string}: Log">
            <filter>out and 'log' in out</filter>
        </data>
        <data name="out_el" format="txt" from_work_dir="log_extended_result.txt" label="${tool.name} on ${on_string}: Extended log">
            <filter>out and 'extended_log' in out</filter>
        </data>
        <data name="out_config" format="txt" from_work_dir="config.txt" label="${tool.name} on ${on_string}: Config file">
            <filter>out and 'config' in out</filter>
        </data>
    </outputs>
    <tests>

        <test expect_num_outputs="6">
            <conditional name="reads_cond">
                <param name="reads_sel" value="separate"/>
                <param name="forward_reads" value="forward.fasta.gz"/>
                <param name="reverse_reads" value="reverse.fasta.gz"/>
            </conditional>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

            <param name="seed_input" value="seed.fasta"/>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="110"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="9">
            <conditional name="reads_cond">
                <param name="reads_sel" value="combined"/>
                <param name="combined_reads" value="combined.fasta.gz"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>
            <param name="reference" value="reference.fasta.gz"/>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                    <param name="genome_range_min" value="12001"/>
                    <param name="genome_range_max" value="20001"/>
                </conditional>

                <param name="read_length" value="150"/>
                <param name="insert_size" value="301"/>

                <param name="extend_seed_directly" value="no"/>
                <param name="kmer" value="40"/>

                <param name="insert_size_auto" value="yes"/>
                <param name="use_quality_scores" value="yes"/>

            <param name="out" value="log,extended_log,config"/>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="14"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>

            <output name="out_l">
                <assert_contents>
                    <has_text_matching expression=".+Assembly 1 finished.+"/>
                </assert_contents>
            </output>
            <output name="out_el">
                <assert_contents>
                    <has_text_matching expression=".+Assembly 1 finished.+"/>
                </assert_contents>
            </output>
            <output name="out_config">
                <assert_contents>
                    <has_n_lines n="39"/>
                    <has_line line="Project:"/>
                    <has_text_matching expression=".+"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="10">
            <conditional name="reads_cond">
                <param name="reads_sel" value="combined"/>
                <param name="combined_reads" value="combined.fasta"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>

                <param name="platform" value="illumina"/>

                <param name="extend_seed_directly" value="no"/>
                <param name="kmer" value="40"/>
                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

            <conditional name="reference_cond">
                <param name="use_reference" value="true"/>
                <param name="reference" value="reference.fasta"/>
                <param name="variance_detection" value="true"/>
            </conditional>
            <param name="out" value="log,extended_log,config"/>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="111"/>
                </assert_contents>
            </output>

            <output name="out_v">
                <assert_contents>
                    <has_n_lines n="21"/>
                    <has_line line="##fileformat=VCFv4.0"/>
                    <has_text_matching expression="#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO"/>
                </assert_contents>
            </output>

            <output name="out_l">
                <assert_contents>
                    <has_text_matching expression=".+Assembly 1 finished.+"/>
                </assert_contents>
            </output>
            <output name="out_el">
                <assert_contents>
                    <has_text_matching expression=".+Assembly 1 finished.+"/>
                </assert_contents>
            </output>
            <output name="out_config">
                <assert_contents>
                    <has_n_lines n="39"/>
                    <has_line line="Project:"/>
                    <has_text_matching expression=".+"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="6">
            <conditional name="reads_cond">
                <param name="reads_sel" value="separate"/>
                <param name="forward_reads" value="forward.fasta.gz"/>
                <param name="reverse_reads" value="reverse.fasta.gz"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>

                <param name="platform" value="ion"/>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="110"/>
                </assert_contents>
            </output>
            <output name="out_ct">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="14">
            <conditional name="reads_cond">
                <param name="reads_sel" value="combined"/>
                <param name="combined_reads" value="combined.fasta"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>
            <conditional name="reference_cond">
                <param name="use_reference" value="true"/>
                <param name="reference" value="reference.fasta"/>
                <conditional name="heteroplasmy_cond">
                    <param name="detect_heteroplasmy" value="true"/>
                    <param name="maf" value="0.008"/>
                </conditional>
            </conditional>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ct">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>

            <output name="out_h">
                <assert_contents>
                    <has_n_lines n="8"/>
                    <has_text_matching expression="#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO"/>
                </assert_contents>
            </output>
            <output name="out_ha">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_lth">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_pn">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_pna">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ltn">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_cm">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_cl">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="6">
            <conditional name="reads_cond">
                <param name="reads_sel" value="combined"/>
                <param name="combined_reads" value="combined.fasta"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>

                <conditional name="type_cond">
                    <param name="type_sel" value="chloro"/>
                </conditional>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="110"/>
                </assert_contents>
            </output>
            <output name="out_ct">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="6">
            <conditional name="reads_cond">
                <param name="reads_sel" value="combined"/>
                <param name="combined_reads" value="combined.fasta"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>
            <conditional name="reference_cond">
                <param name="use_reference" value="true"/>
                <param name="reference" value="reference.fasta"/>
            </conditional>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito_plant"/>
                    <param name="chloroplast_sequence" value="chloroplast.fasta"/>
                </conditional>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ct">
                <assert_contents>
                    <has_n_lines n="8"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="112"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="14">
            <conditional name="reads_cond">
                <param name="reads_sel" value="combined"/>
                <param name="combined_reads" value="combined.fasta"/>
            </conditional>
            <param name="seed_input" value="seed.fasta"/>
            <conditional name="reference_cond">
                <param name="use_reference" value="true"/>
                <param name="reference" value="reference.fasta"/>
                <conditional name="heteroplasmy_cond">
                    <param name="detect_heteroplasmy" value="true"/>
                    <param name="maf" value="0.008"/>
                    <param name="pcr_free" value="true"/>
                </conditional>
            </conditional>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ct">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>

            <output name="out_h">
                <assert_contents>
                    <has_n_lines n="8"/>
                    <has_text_matching expression="#CHROM	POS	ID	REF	ALT	QUAL	FILTER	INFO"/>
                </assert_contents>
            </output>
            <output name="out_ha">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_lth">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_pn">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_pna">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ltn">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_cm">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_cl">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="6">
            <conditional name="reads_cond">
                <param name="reads_sel" value="separate"/>
                    <param name="forward_reads" value="forward.fasta.gz"/>
                    <param name="reverse_reads" value="reverse.fasta.gz"/>
            </conditional>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

                <param name="insert_range" value="1.9"/>
                <param name="insert_range_strict" value="1.3"/>

            <param name="seed_input" value="seed.fasta"/>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="110"/>
                </assert_contents>
            </output>
            <output name="out_ct">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>

        <test expect_num_outputs="8">
            <conditional name="reads_cond">
                <param name="reads_sel" value="separate"/>
                    <param name="forward_reads" value="forward.fasta.gz"/>
                    <param name="reverse_reads" value="reverse.fasta.gz"/>
            </conditional>

                <conditional name="type_cond">
                    <param name="type_sel" value="mito"/>
                </conditional>

                <param name="save_assembled_reads" value="true"/>

            <param name="seed_input" value="seed.fasta"/>

            <output name="out_c">
                <assert_contents>
                    <has_n_lines n="110"/>
                </assert_contents>
            </output>
            <output name="out_ua">
                <assert_contents>
                    <has_n_lines n="0"/>
                </assert_contents>
            </output>
        </test>
    </tests>
    <help><![CDATA[
.. class:: infomark

**What it does**

*NOVOPlasty* is a de novo assembler and heteroplasmy/variance caller for short circular genomes.

**Input**

- suitable seed: There are different types of seed possible: A single read from the dataset that originates from the organelle genome. A organelle sequence derived from the same or a related species. A complete organelle sequence of a more distant species (recommended when there is no close related sequence available)
- input reads: Either two separate files(forward and reverse) or a merged fastq/fasta file. Multiple libraries as input is not yet supported. There is also an Ion Torrent option, but it does not produce the best results.
- reference: The assembly will still be de novo, but references of the same genus can be used as a guide to resolve duplicated regions in the plant mitochondria or the inverted repeat in the chloroplast.

**Output**

*Assembly*

- Contigs: This file contains all the assembled contigs.
- Circularized assembly: When NOVOPlasty is able to circularize one contig, without any additional contigs being produced, it will just output this circularized fasta file.
- Uncircularized assembly
- Merged contigs: When there are multiple contigs, NOVOPlasty will try to combine all contigs in to a complete circular genome, all the different possibilities can be found in this file.
- Contigs Tmp: If non of the above files are outputted or are empty, you can retrieve some contigs from this file.

*Variance*

- Variance: When the variance detection option is selected, an additional VCF file will be outputted.

*Heteroplasmy*

- Heteroplasmy: This VCF file contains all the detected heteroplasmy positions.
- Heteroplasmy assemblies: NOVOPlasty will assemble around each position of the above VCF output. The resulting assemblies will be outputted in this fasta file.
- Linkage table heteroplasmy: This file contains all the polymorphisms that are fully/partially/not linked with each detected heteroplasmic position.
- Possible NUMTs / Possible NUMTs assemblies / Linkage table NUMTs: These are the same files as the above three, but then for all the polymorphisms that were identified as NUMT origin.
- Circos mutations / Circos links: These files can be used to draw figures with Circos.

*Others*

- Log: This is a basic log file with the information that shows up on your terminal.
- Extended log: An elaborate log file.
- Config file

.. class:: infomark

**References**

More information are available on `GitHub <https://github.com/ndierckx/NOVOPlasty/>`_.
    ]]></help>
    <citations>
        <citation type="doi">10.1093/nar/gkw955</citation>
        <citation type="doi">10.1093/nargab/lqz011</citation>
    </citations>
</tool>