Barrier Free Living residential walk in shower pans are designed to provide a safe, independent and convenient alternative to a traditional bathtub. The danger of stepping into a bathtub is eliminated, and a low threshold handicap accessible roll-in shower base can be used by people of all abilities. Shower bases are a labor saving economical, hygienic alternative to a ceramic tile floor, yet are engineered to allow the installation of ceramic tile walls.
Commercial shower bases are offered which adhere to ADA standards for size, and shower pan clearance. Over 40 styles and sizes of accessible bases engineered to make installation simple with no requirement to lower a floor. There are many models designed to make a bathtub to shower conversion a quick and simple installation so that the plumbing can remain in place.
Overall, a Barrier Free Living walk in shower base is a lifetime durable solution to safe, comfortable, independent bathing and has a 30-year warranty.
Custom made shower pans in any size, drain location or configuration are also available.


text:
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Greatbone.Web
{
    /// <summary>
    /// The descriptor for an action method.
    /// </summary>
    public sealed class WebAction : WebTarget
    {
        readonly WebWork work;

        // relative path
        readonly string relative;

        readonly bool async;

        // the name of subscript parameter (the second parameter), may be null
        readonly string subscript;

        // the action pathing
        readonly string pathing;

        // tool annotation for ui
        internal readonly ToolAttribute tool;

        // state check annotation
        internal readonly StateAttribute state;

        // 4 possible forms of the action method
        readonly Action<WebContext> @do;
        readonly Func<WebContext, Task> doAsync;
        readonly Action<WebContext, string> do2;
        readonly Func<WebContext, string, Task> do2Async;

        readonly List<TagAttribute> comments;

        internal WebAction(WebWork work, MethodInfo mi, bool async, string subscript) : base(mi.Name == "default" ? string.Empty : mi.Name, mi)
        {
            this.work = work;
            this.relative = Key == string.Empty ? "./?inner=true" : Key;
            this.async = async;
            this.subscript = subscript;

            this.tool = (ToolAttribute) mi.GetCustomAttribute(typeof(ToolAttribute), true);
            this.state = (StateAttribute) mi.GetCustomAttribute(typeof(StateAttribute), true);

            // create a doer delegate
            if (async)
            {
                if (HasSubscript)
                {
                    do2Async = (Func<WebContext, string, Task>) mi.CreateDelegate(typeof(Func<WebContext, string, Task>), work);
                }
                else
                {
                    doAsync = (Func<WebContext, Task>) mi.CreateDelegate(typeof(Func<WebContext, Task>), work);
                }
            }
            else
            {
                if (HasSubscript)
                {
                    do2 = (Action<WebContext, string>) mi.CreateDelegate(typeof(Action<WebContext, string>), work);
                }
                else
                {
                    @do = (Action<WebContext>) mi.CreateDelegate(typeof(Action<WebContext>), work);
                }
            }

            // comments
            foreach (var m in mi.GetCustomAttributes())
            {
                if (m is TagAttribute c)
                {
                    if (comments == null) comments = new List<TagAttribute>(4);
                    comments.Add(c);
                }
            }

            // resolve the action pathing
            StringBuilder sb = new StringBuilder(work.Pathing);
            sb.Append(Key);
            if (HasSubscript)
            {
                sb.Append('-').Append('<').Append(subscript).Append('>');
            }
            pathing = sb.ToString();
        }

        public WebWork Work => work;

        public string Relative => relative;

        public bool IsAsync => async;

        public bool HasSubscript => subscript != null;

        public string Pathing => pathing;

        public bool HasTool => tool != null;

        public ToolAttribute Tool => tool;

        public List<TagAttribute> Comments => comments;

        public bool CheckState(WebContext wc, object[] stack, int level)
        {
            return state == null || stack == null || state.Check(wc, stack, level);
        }

        internal void Do(WebContext wc, string subscript)
        {
            if (HasSubscript)
            {
                do2(wc, subscript);
            }
            else
            {
                @do(wc);
            }
        }

        // invoke the right method
        internal async Task DoAsync(WebContext wc, string subscript)
        {
            if (HasSubscript)
            {
                await do2Async(wc, subscript);
            }
            else
            {
                await doAsync(wc);
            }
        }
    }
}

redpajama_set_name: RedPajamaGithub


Not only leafy vegetables but also large vegetables and fruits can be easily cultivated at home with this hydroponic oxygen system. Anyone can harvest 3-4 times more than soil cultivation, and the growth speed is 1.5 to 2 times faster.
Instantly dominate Instagram with this incredible new app INSTADOM.
Smart Tech Healthcare 2018 - Streamlining New Horizons of Technology in Healthcare, Conference & Exhibition will take place on 1st - 2nd, February 2018, Movenpick (Hyatt), Bengaluru, India.
Puynam.com has committed and successfully completed ISO 9001:2015 Consultancy for J S Engineering by implementing Quality Management System to conforming ISO 9001:2015 Certification.
I Million Impressions Global Experts of USA (America), Europe, Asia Pacific, Middle East, Asia Pacific and Africa at Hematology conferences, Hematological Conferences, Blood disorder Conferences happening from June 18-20, 2018 London, UK.
Shubhashish IT Services a preeminent website design company and mobile app development firm located in the USA is celebrating an auspicious moment of successfully completing 3 years which includes many successful projects. The company was founded in 2015 by some of the renowned and brilliant experts.
LCR Capital Partners is pleased to officially announce the appointment of Ashish Saraff as Director, India (EB-5).
RAIDIX announces cooperation with a Chinese system integrator Cloud Descendant Information Technology (Shanghai) Co., Ltd.
Start the new year off right with home safety in mind by joining us this January in recognizing National Radon Action Month.
Vembu is pleased to announce the release of Vembu BDR Suite v3.9.0 which offers Business Continuity, Compliance, UX, and the Ease of Backup & Restore to meet the different needs of Diverse IT environments.
IIH Global, holding 5+ years of experience in web, mobile and PHP development, the organization has sufficiently earned experience in serving the diverse requirements of customers from various industry verticals.
In the world of software Aryson Technologies is a rising name. In a very short span of time the company has gained huge reputation and recognition among the big players of software in the field of data recovery as well as data migration.
SMi Group reports: Polish Armed Forces to provide updates on their Mobile Deployable Communications in Warsaw in February.
Bursting with jokes and laughter, Season 2 of Vdesi Comedy Night returns to The Huddle Sports Bar & Grill in Citymax Hotel Bur Dubai on 5th February and The MAXX Music Bar in Citymax Hotel Al Barsha on 6th February.
From January 1 to February 1, 2018 in the desert King Abdulaziz Camel Festival takes place. One of the most notable activities of the festival is the 360 dome projection, created by Russian studios Sila Sveta and Dobro.
UnicoTaxi Provides a White label Taxi Application for a Taxi Companies and Entrepreneurs. We Provide a Taxi Solution with Versatile and Cost-Effective Taxi Dispatch System, that bridges Gap between Taxi Companies and Discerning Customers.
Data services provider and marketing technology innovator Ampliz is all geared up for the launch of its reinvented cloud-based data search and hosting platform for businesses – AmplizDATA. The launch is slated for this Monday (22nd Jan, 2018).
The event is essential for anyone considering purchasing property abroad.
TeRra Han, well known for a prodigy and musical genius of South Korea will have a Carnegie Hall recital January 30th 8pm.
Bill Thomas Releases Paranormal Book Entitled "The Three Souls"
The book is available as an ebook and a paperback.
This was announced in the review of the technology companies worldwide by The Technology Headline Magazine.
Rick Mohrman of executive search firm Brooke Chase Associates, Inc., is pleased to announce the successful placement of Gary Parker as Chief Operating Officer with Kentucky Trailer.
By Brooke Chase Associates, Inc.
SMi Group Reports: 4th annual Future Armoured Vehicles Central and Eastern Europe conference will return to Prague, Czech Republic on 21st and 22nd May 2018.
Celebrate Entertainment is Sydney's leading DJ hire company. In an interview with Eleven Media, they confirmed that Sydney continues to attract the cream of talent in the entertainment world, including DJ's.
Akadema has launched its new website. Brand new visuals and a live chat are among new features.
West Palm Beach Location to Host a Grand Reopening Celebration on Jan. 24.
Partnering with longtime friends and collaborators WKCD productions for the visual side of the show, Stuckey says that the show is designed to promote bands and artists that are working hard to make music full time.
Epsilon Provides Access to a Continental Edge Ecosystem of Data Centers and Subsea Cable Providers Through Infiny, the On-Demand Connectivity Platform.
The Jennifers, the new novel by writer Jenny G. Perry, depicts the everyday lives of a gaggle of girlfriends who have grown up together but have grown in different ways.
Personal Attention, LLC helps customers create memorable moments by offering the ultimate experience in hospitality and access.
Colliers' Erickson: Lease Illustrates Growing "Retailtainment" Trend at Shopping Centers.
The Network Journal announces its 2018 list of 25 Influential Black Women in Business. The celebratory luncheon is on March 16th, located in New York City.
Past CEO of Australian Institute of Architects, David Parken and State Manager of Consult Australia, Launch the Design Futures Council.
TKG, the leading producer of regulatory focused webcasts, has announced today that Jonathan Pasternak, Partner, DelBello Donnellan Weingarten Wise & Wiederkehr LLP will speak at a webcast entitled: "Recent Trends, Developments and Updates in Bankruptcy & Restructuring Law: What You Should Not Miss LIVE Webcast".
Leader in Hydrological and Meteorological Instrumentation adds Expertise in Solar Irradiation Systems.


Tilt your device to steer the rocket - your goal is to hit every cloud, the game is over, when you miss a cloud. The rocket will accelerate all the time, so the game gets harder and harder! Try to get the highest score and be better than everyone else!
Hit the Clouds now available at google play!


text:
// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2013, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of Knut Reinert or the FU Berlin nor the names of
//       its contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: David Weese <david.weese@fu-berlin.de>
// ==========================================================================

#include <iostream>

#ifndef SEQAN_HEADER_STORE_IO_SAM_H
#define SEQAN_HEADER_STORE_IO_SAM_H

namespace SEQAN_NAMESPACE_MAIN
{

//////////////////////////////////////////////////////////////////////////////
// Parsing functions
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// _parseReadCigar

    template <typename TFile, typename TCigarString, typename TChar>
    inline void
    _parseReadCigar(TFile & file, TCigarString & cigar, TChar & c)
    {
//IOREV _nodoc_ _hasCRef_ could be simplified by using other _is or _parse calls
        typedef typename Value<TCigarString>::Type  TCigarElement;
        typedef typename TCigarElement::TCount      TCount;

        clear(cigar);

        // if the CIGAR is not set and '*'
        if (c == '*')
        {
            c = _streamGet(file);
            return;
        }

        while (!_streamEOF(file))
        {
            TCount count = _parseReadNumber(file, c);
            if (c >= 'a' && c <= 'z')
                c = c + 'A' - 'a';
            appendValue(cigar, TCigarElement(c, count));

            c = _streamGet(file);
            if (c == ' ' || c == '\t' || c == '\n') break;
        }
    }

//////////////////////////////////////////////////////////////////////////////
// _parseReadSamIdentifier

    template<typename TFile, typename TString, typename TChar>
    inline void
    _parseReadSamIdentifier(TFile & file, TString & str, TChar& c)
    {
//IOREV _nodoc_ _hasCRef_ _duplicate_ same as generic _parseUntilWhitespace?
        if (c == ' ' || c == '\t' || c == '\n') return;
        appendValue(str, c);
        while (!_streamEOF(file))
        {
            c = _streamGet(file);
            if (c == ' ' || c == '\t' || c == '\n') return;
            appendValue(str, c);
        }
    }

//////////////////////////////////////////////////////////////////////////////
// _parseIsDna

    template<typename TChar>
    inline bool
    _parseIsDna(TChar const & c)
    {
//IOREV _bug_ according to Dna5 doc c is already uppercase, so it should be (c == x) || (c - 'A' + 'a' == x) OR JUST: return tolower(c) == tolower(x);
        char x = TChar(Dna5(c));
        return (c == x) || (c + 'A' - 'a' == x);
    }

//////////////////////////////////////////////////////////////////////////////
//_parseReadDnaSeq

    template<typename TFile, typename TString, typename TChar>
    inline void
    _parseReadDnaSeq(TFile & file, TString & str, TChar & c)
    {
//IOREV _nodoc_ _hasCRef_ _duplicate_ same as generic _parseUntilWhitespace?
        TChar first = c;
        if (!_streamEOF(file))
            c = _streamGet(file);

        if (!_parseIsDna(first))
            return;
        appendValue(str, first, Generous());

        for (; !_streamEOF(file) && _parseIsDna(c); c = _streamGet(file))
            appendValue(str, c, Generous());
    }

//////////////////////////////////////////////////////////////////////////////
// _parseIsPhredQual

    template <typename TChar>
    inline bool
    _parseIsPhredQual(TChar c)
    {
//IOREV _nodoc_ what does the title mean? same as return isprint(c) && c != ' '
        return c >= '!' && c <= '~';
    }

//////////////////////////////////////////////////////////////////////////////
// _parseReadSeqQual
//

    template<typename TFile, typename TQualString, typename TChar>
    inline void
    _parseReadSeqQual(TFile & file, TQualString & str, TChar & c)
    {
//IOREV _nodoc_ unclearn what this actually does
        typedef typename Size<TQualString>::Type                TSize;
        typedef typename Iterator<TQualString, Standard>::Type  TIter;

        if (!_parseIsPhredQual(c)) return;

        TIter itBegin = begin(str, Standard());
        TIter it = itBegin;
        TSize rest = length(str);

        do {
            int q = c - '!';
            if (!_streamEOF(file))
                c = _streamGet(file);
            else
                if (rest > 1)
                    rest = 1;

            if (q == '*' - '!' && !_parseIsPhredQual(c) && it == itBegin)
                return;

            if (rest != 0)
            {
                assignQualityValue(*it, q);
                ++it;
                --rest;
            }
        } while (_parseIsPhredQual(c) && !_streamEOF(file));
    }

//////////////////////////////////////////////////////////////////////////////
// _parseReadCharsUntilEndOfLine
//
// Reads all symbols till the next '\n' and writes them in the CharString str
// the c is the first character after the '\n'.

    template<typename TFile, typename TChar>
    inline void
    _parseReadCharsUntilEndOfLine(TFile & file, String<char> & str, TChar& c)
    {
//IOREV replace with generic _parseLine() function that ignores '\r' (this calls adds a lonely '\r' to the end of str if file is windows-formatted)
        // read all chars till '\n'
        while (c != '\n')
        {
            appendValue(str, c, Generous());
            if (_streamEOF(file)) return;
            c = _streamGet(file);
        }

        // read the first char after the '\n'
        if (!_streamEOF(file))
            c = _streamGet(file);
    }

//////////////////////////////////////////////////////////////////////////////
// appendAlignment

    template<typename TSpec, typename TConfig, typename TId, typename TPos, typename TGaps>
    inline typename Size<typename FragmentStore<TSpec, TConfig>::TAlignedReadStore>::Type
    appendAlignment(
        FragmentStore<TSpec, TConfig> & fragStore,
        TId readId,
        TId contigId,
        TPos beginPos,
        TPos endPos,
        TGaps const & gaps)
    {
        typedef FragmentStore<TSpec, TConfig> TFragmentStore;
        typedef typename Value<typename TFragmentStore::TAlignedReadStore>::Type TAlignedElement;

        TId id = length(fragStore.alignedReadStore);
        TAlignedElement alignedElem = TAlignedElement(id, readId, contigId, beginPos, endPos, gaps);
        appendValue(fragStore.alignedReadStore, alignedElem);

        return id;
    }

//////////////////////////////////////////////////////////////////////////////
// read functions for Sam
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// _generatePairMatchIds
//
    template <typename TPos, typename TId>
    struct MatchMateInfo_
    {
        TId     readId;
        TId     contigId;
        TId     pairMatchId;
        TId     matePairId;//:(sizeof(TId)*8-1);
        TPos    beginPos;
        bool    reversed;
    };

    template <typename TFragStore>
    struct AlignedMateLess_
    {
        TFragStore &fragStore;

        AlignedMateLess_(TFragStore &fragStore_) :
            fragStore(fragStore_) {}

        template <typename TAlignedRead>
        inline bool
        operator() (TAlignedRead const& a, TAlignedRead const& b) const
        {
            if (a.contigId < b.contigId) return true;
            if (a.contigId > b.contigId) return false;

            typename TFragStore::TContigPos posA = _min(a.beginPos, a.endPos);
            typename TFragStore::TContigPos posB = _min(b.beginPos, b.endPos);
            if (posA < posB) return true;
            if (posA > posB) return false;

            bool reversedA = (a.endPos < a.beginPos);
            bool reversedB = (b.endPos < b.beginPos);
            if (reversedA != reversedB) return reversedB;

            typedef typename TFragStore::TMatePairStore     TMatePairStore;
            typedef typename Value<TMatePairStore>::Type    TMatePair;
            typename TMatePair::TId matePairIdB = TMatePair::INVALID_ID;

            if (a.readId >= length(fragStore.readStore))
                return false;

            if (b.readId < length(fragStore.readStore))
                matePairIdB = fragStore.readStore[b.readId].matePairId;

            return (fragStore.readStore[a.readId].matePairId < matePairIdB);
        }
    };

    struct MatchMateInfoLess_
    {
        template <typename TMInfo>
        inline bool
        operator() (TMInfo const &a, TMInfo const &b) const
        {
            if (a.contigId < b.contigId) return true;
            if (a.contigId > b.contigId) return false;
            if (a.beginPos < b.beginPos) return true;
            if (a.beginPos > b.beginPos) return false;
            if (a.reversed != b.reversed) return b.reversed;
            if (a.matePairId < b.matePairId) return true;
            if (a.matePairId > b.matePairId) return false;
            return (a.pairMatchId < b.pairMatchId);
        }
    };

    template <typename TAlignedRead, typename TMInfo, typename TFragStore>
    inline int
    _compareAlignedReadAndMateInfo(TAlignedRead const &a, TMInfo const &b, TFragStore const &fragStore)
    {
        if (a.contigId < b.contigId) return -1;
        if (a.contigId > b.contigId) return 1;

        typename TFragStore::TContigPos posA = _min(a.beginPos, a.endPos);
        if (posA < b.beginPos) return -1;
        if (posA > b.beginPos) return 1;

        bool reversedA = (a.endPos < a.beginPos);
        if (!reversedA &&  b.reversed) return -1;
        if ( reversedA && !b.reversed) return 1;

        typedef typename TFragStore::TMatePairStore     TMatePairStore;
        typedef typename Value<TMatePairStore>::Type    TMatePair;
        typename TMatePair::TId matePairIdA = TMatePair::INVALID_ID;

        if (a.readId < length(fragStore.readStore))
            matePairIdA = fragStore.readStore[a.readId].matePairId;

        if (matePairIdA < b.matePairId) return -1;
        if (matePairIdA > b.matePairId) return 1;
        return 0;
    }

    template<typename TSpec, typename TConfig, typename TMatchMateInfos>
    inline void
    _generatePairMatchIds (
        FragmentStore<TSpec, TConfig> & fragStore,
        TMatchMateInfos & matchMateInfos)
    {
        typedef FragmentStore<TSpec, TConfig>                           TFragmentStore;
        typedef typename TFragmentStore::TAlignedReadStore              TAlignedReadStore;
        typedef typename Iterator<TAlignedReadStore, Standard>::Type    TIter;
        typedef typename Iterator<TMatchMateInfos, Standard>::Type      TMIter;

        TIter it = begin(fragStore.alignedReadStore, Standard());
        TIter itEnd = end(fragStore.alignedReadStore, Standard());
        TMIter mit = begin(matchMateInfos, Standard());
        TMIter mitEnd = end(matchMateInfos, Standard());

        if (it == itEnd || mit == mitEnd) return;

        // sort the aligned read store by: begin position, contig name
        std::sort(it,  itEnd,  AlignedMateLess_<TFragmentStore>(fragStore));
        std::sort(mit, mitEnd, MatchMateInfoLess_());

        while (true)
        {
            int cmp = _compareAlignedReadAndMateInfo(*it, *mit, fragStore);

            if (cmp == 0)   // both are equal -> link them
                if (it->pairMatchId > mit->pairMatchId)     // avoid id swap and instead decide for
                    it->pairMatchId = mit->pairMatchId;     // the smaller of both ids

            if (cmp >= 0)   // MateInfo is less or equal
                if (++mit == mitEnd)
                    return;

            if (cmp <= 0)   // AlignedRead is less or equal
                if (++it == itEnd)
                    return;
        }
    }

//////////////////////////////////////////////////////////////////////////////
// read

///.Function.read.param.tag.type:Tag.File Format.tag.Sam

    struct FragStoreImportFlags
    {
        bool importRead:1;
        bool importReadSeq:1;
        bool importReadName:1;
        bool importReadAlignment:1;
        bool importReadAlignmentQuality:1;
        bool importReadAlignmentTags:1;

        FragStoreImportFlags():
            importRead(true),
            importReadSeq(true),
            importReadName(true),
            importReadAlignment(true),
            importReadAlignmentQuality(true),
            importReadAlignmentTags(true)
        {}
    };

    inline void
    clear(FragStoreImportFlags & flags)
    {
        flags.importRead = false;
        flags.importReadSeq = false;
        flags.importReadName = false;
        flags.importReadAlignment = false;
        flags.importReadAlignmentQuality = false;
        flags.importReadAlignmentTags = false;
    }

    template<typename TStreamOrReader, typename TSpec, typename TConfig, typename TTag>
    inline void
    _readImpl(TStreamOrReader & streamOrReader,
              FragmentStore<TSpec, TConfig> & fragStore,
              TTag const & tag,
              FragStoreImportFlags const & importFlags)
    {
        typedef FragmentStore<TSpec, TConfig> TFragmentStore;
        typedef typename TFragmentStore::TContigPos TContigPos;
        typedef typename Id<TFragmentStore>::Type TId;

        // data structure to temporarily store the gaps that need to be inserted in the contig sequences
        typedef MatchMateInfo_<TContigPos, TId> TMatchMateInfo;
        typedef String<TMatchMateInfo> TMatchMateInfos;
        typedef StringSet<String<typename TFragmentStore::TContigGapAnchor>, Owner<ConcatDirect<> > > TContigAnchorGaps;

        // data structure to temporarily store information about match mates
        TMatchMateInfos matchMateInfos;
        TContigAnchorGaps contigAnchorGaps;

        refresh(fragStore.contigNameStoreCache);

        // Setup a BamIOContext for I/O.
        typedef BamIOContext<typename TFragmentStore::TContigNameStore> TBamIOContext;
        TBamIOContext bamIOContext(fragStore.contigNameStore, fragStore.contigNameStoreCache);

        // Read in the header.  We will subsequently ignore it and use the information indirectly just using the
        // sequence names if any.
        BamHeader bamHeader;
        if (readRecord(bamHeader, bamIOContext, streamOrReader, tag) != 0)
        {
            std::cerr << "ERROR: Problem reading header from SAM file.\n";
            return;
        }

        // fill up contig entries for each contig name that appears in the header
        resize(fragStore.contigStore, length(fragStore.contigNameStore));

        // Read in alignments section
        _readAlignments(streamOrReader, bamIOContext, fragStore, contigAnchorGaps, matchMateInfos, tag, importFlags);

        if (importFlags.importReadAlignment)
        {
            // set the match mate IDs using the information stored in matchMateInfos
            _generatePairMatchIds(fragStore, matchMateInfos);

            convertPairWiseToGlobalAlignment(fragStore, contigAnchorGaps);
        }
    }

    template <typename TFile, typename TSpec, typename TConfig>
    inline void
    read(TFile & file,
         FragmentStore<TSpec, TConfig> & fragStore,
         Sam,
         FragStoreImportFlags const & importFlags)
    {
        // Construct a RecordReader from the input file.
        RecordReader<TFile, SinglePass<> > reader(file);
        if (atEnd(reader))
            return;  // Done, file is empty.
        _readImpl(reader, fragStore, Sam(), importFlags);
    }

#if SEQAN_HAS_ZLIB
    template <typename TFile, typename TSpec, typename TConfig>
    inline void
    read(TFile & file,
         FragmentStore<TSpec, TConfig> & fragStore,
         Bam,
         FragStoreImportFlags const & importFlags)
    {
        _readImpl(file, fragStore, Bam(), importFlags);
    }
#endif  // #if SEQAN_HAS_ZLIB

    template <typename TFile, typename TSpec, typename TConfig>
    inline void
    read(
        TFile & file,
        FragmentStore<TSpec, TConfig> & fragStore,
        Sam)
    {
        read(file, fragStore, Sam(), FragStoreImportFlags());
    }

#if SEQAN_HAS_ZLIB
    template <typename TFile, typename TSpec, typename TConfig>
    inline void
    read(
        TFile & file,
        FragmentStore<TSpec, TConfig> & fragStore,
        Bam)
    {
        read(file, fragStore, Bam(), FragStoreImportFlags());
    }
#endif  // #if SEQAN_HAS_ZLIB

//////////////////////////////////////////////////////////////////////////////
// _readAlignments
//
// reads in alignement sections from a Sam file

    template <typename TFragmentStore>
    struct FragStoreSAMContext
    {
        typedef typename Id<TFragmentStore>::Type                                   TId;
        typedef typename Value<typename TFragmentStore::TAlignedReadStore>::Type    TAlignedElement;
        typedef typename TAlignedElement::TGapAnchors                               TReadGapAnchors;
        typedef String<typename TFragmentStore::TContigGapAnchor>                   TContigAnchorGaps;
        typedef typename TFragmentStore::TReadSeq                                   TReadSeq;

        TId                 readId;
        TId                 contigId;
        TReadGapAnchors     readGapAnchors;
        TContigAnchorGaps   contigGapAnchors;

        // Buffer for SAM tags.
        CharString tags;
        // Buffer for the read sequence.
        TReadSeq readSeq;

        // Buffer for the current BamAlignmentRecord.
        BamAlignmentRecord bamRecord;
    };

    template <typename TStreamOrReader, typename TNameStore, typename TNameStoreCache, typename TSpec, typename TConfig, typename TContigAnchorGaps, typename TMatchMateInfos, typename TTag>
    inline void
    _readAlignments(
        TStreamOrReader & streamOrReader,
        BamIOContext<TNameStore, TNameStoreCache> & bamIOContext,
        FragmentStore<TSpec, TConfig> & fragStore,
        TContigAnchorGaps & contigAnchorGaps,
        TMatchMateInfos & matchMateInfos,
        TTag const & tag,
        FragStoreImportFlags const & importFlags)
    {
//IOREV _nodoc_ docusmentation in code, but unclear
        // create dummy entries in Sam specific aligned read quality store and aligned read tag store
        // is needed so the ID in the aligned store can be use to access the other stores
        // even if there exists previous entries without
        typedef FragmentStore<TSpec, TConfig> TFragmentStore;
        typedef typename TFragmentStore::TAlignQualityStore TAlignQualityStore;
        typedef typename TFragmentStore::TReadSeqStore TReadSeqStore;
        typedef typename Size<TReadSeqStore>::Type TReadSeqStoreSize;
        typedef typename Value<TAlignQualityStore>::Type TAlignQuality;

        TAlignQuality q;
        q.score = maxValue(q.score);
        int diff = length(fragStore.alignedReadStore) - length(fragStore.alignQualityStore);
        for(int i = 0; i < diff; ++i)
            appendValue(fragStore.alignQualityStore, q, Generous());

        diff = length(fragStore.alignedReadStore) - length(fragStore.alignedReadTagStore);
        for(int i = 0; i < diff; ++i)
            appendValue(fragStore.alignedReadTagStore, "", Generous());

        // read in alignments
        FragStoreSAMContext<TFragmentStore> contextSAM;
//        refresh(fragStore.contigNameStoreCache);  // was done for the BamIOContext already
        refresh(fragStore.readNameStoreCache);

        while (!atEnd(streamOrReader))
            _readOneAlignment(streamOrReader, bamIOContext, fragStore, contigAnchorGaps, matchMateInfos, contextSAM,
                              importFlags, tag);

        if (importFlags.importReadSeq)
        {
            TReadSeqStoreSize emptyReads = 0;
            for(TReadSeqStoreSize i = 0; i < length(fragStore.alignedReadStore); ++i)
                if (empty(fragStore.readSeqStore[fragStore.alignedReadStore[i].readId]))
                {
                    ++emptyReads;
    //                std::cerr << "Read sequence empty for " << fragStore.readNameStore[fragStore.alignedReadStore[i].readId] << std::endl;
                }
            if (emptyReads != 0)
                std::cerr << "Warning: " << emptyReads << " read sequences are empty." << std::endl;
        }
    }

    template <typename TReadSeq, typename TCigar, typename TPos, typename TId, typename TFragmentStore>
    inline void
    _samAppendAlignment(
        TFragmentStore &fragStore,
        TReadSeq const &readSeq,
        TCigar &cigar,
        TPos &beginPos, TPos &endPos,
        TId &pairMatchId,
        FragStoreSAMContext<TFragmentStore> & contextSAM)
    {
        typedef typename TFragmentStore::TAlignedReadStore                      TAlignedReadStore;
        typedef typename Value<TAlignedReadStore>::Type                         TAlignedRead;
        typedef Gaps<TReadSeq, AnchorGaps<typename TAlignedRead::TGapAnchors> > TReadGaps;

        // insert alignment gaps
        clear(contextSAM.readGapAnchors);
        TReadGaps readGaps(readSeq, contextSAM.readGapAnchors);
        unsigned beginGaps = cigarToGapAnchorRead(cigar, readGaps);

        // adapt start or end (on reverse strand) position if alignment begins with gaps
        if (beginPos > endPos)
            endPos += beginGaps;
        else
            beginPos += beginGaps;

        // create a new entry in the aligned read store
        pairMatchId = appendAlignment(fragStore, contextSAM.readId, contextSAM.contigId, beginPos, endPos, contextSAM.readGapAnchors);
    }

    template <typename TCigar, typename TPos, typename TId, typename TFragmentStore>
    inline void
    _samAppendAlignmentWithoutSeq(
        TFragmentStore &fragStore,
        TCigar &cigar,
        TPos &beginPos, TPos &endPos,
        TId &pairMatchId,
        FragStoreSAMContext<TFragmentStore> & contextSAM)
    {
        typedef typename TFragmentStore::TAlignedReadStore                      TAlignedReadStore;
        typedef typename Value<TAlignedReadStore>::Type                         TAlignedRead;
        typedef Gaps<Nothing, AnchorGaps<typename TAlignedRead::TGapAnchors> >  TReadGaps;
        Nothing nothing;

        // insert alignment gaps
        clear(contextSAM.readGapAnchors);
        TReadGaps readGaps(nothing, contextSAM.readGapAnchors);
        unsigned beginGaps = cigarToGapAnchorRead(cigar, readGaps);

        // adapt start or end (on reverse strand) position if alignment begins with gaps
        if (beginPos > endPos)
            endPos += beginGaps;
        else
            beginPos += beginGaps;

        // create a new entry in the aligned read store
        pairMatchId = appendAlignment(fragStore, contextSAM.readId, contextSAM.contigId, beginPos, endPos, contextSAM.readGapAnchors);
    }

//////////////////////////////////////////////////////////////////////////////
// _readOneAlignment
//
// reads in one alignement section from a Sam file

    template <
        typename TStreamOrReader,
        typename TNameStore,
        typename TNameStoreCache,
        typename TSpec,
        typename TConfig,
        typename TContigAnchorGaps,
        typename TMatchMateInfos,
        typename TFragStore,
        typename TTag>
    inline void
    _readOneAlignment(
        TStreamOrReader & streamOrReader,
        BamIOContext<TNameStore, TNameStoreCache> & bamIOContext,
        FragmentStore<TSpec, TConfig> & fragStore,
        TContigAnchorGaps & contigAnchorGaps,
        TMatchMateInfos & matchMateInfos,
        FragStoreSAMContext<TFragStore> & contextSAM,
        FragStoreImportFlags const & importFlags,
        TTag const & tag)
    {
        // Basic types
        typedef FragmentStore<TSpec, TConfig>                                       TFragmentStore;
        typedef FragStoreSAMContext<TFragStore>                                     TSAMContext;
        typedef typename Id<TFragmentStore>::Type                                   TId;
        //typedef typename Size<TFragmentStore>::Type                                 TSize;

        // All fragment store element types
        //typedef typename Value<typename TFragmentStore::TContigStore>::Type         TContigElement;
        //typedef typename Value<typename TFragmentStore::TLibraryStore>::Type        TLibraryStoreElement;
        //typedef typename Value<typename TFragmentStore::TReadStore>::Type           TReadStoreElement;
        typedef typename Value<typename TFragmentStore::TAlignQualityStore>::Type   TAlignQualityElement;

        // Type for sequence in readstore
        typedef typename TFragmentStore::TReadSeq                                   TReadSeq;

        // Type for gap anchor
        typedef typename TFragmentStore::TContigPos                                 TContigPos;
        typedef Gaps<Nothing, AnchorGaps<typename TSAMContext::TContigAnchorGaps> > TContigGapsPW;

        // Type to temporarily store information about match mates
        typedef typename Value<TMatchMateInfos>::Type                               TMatchMateInfo;

        // Read next BamAlignmentRecord and get shortcut.
        if (readRecord(contextSAM.bamRecord, bamIOContext, streamOrReader, tag) != 0)
        {
//  TODO(weese:) skipLine would be required to continue reading after an invalid SAM line but is not yet implemented for Bgzf stream
//            skipLine(streamOrReader);
            std::cerr << "ERROR: Problem reading SAM/BAM record.\n";
            return;
        }
        BamAlignmentRecord & record = contextSAM.bamRecord;

        // Get element of align quality store.
        TAlignQualityElement mapQ;
        mapQ.score = record.mapQ;

        // Get begin and end position.
        TContigPos beginPos = record.beginPos;
        TContigPos endPos = 0;
        _getLengthInRef(record.cigar, endPos);
        endPos = beginPos + endPos;
        if (hasFlagRC(record))
            std::swap(beginPos, endPos);

        // Put read sequence and qualities into readSeq and reverseComplement if necessary.
        TReadSeq & readSeq = contextSAM.readSeq;
        readSeq = record.seq;
        assignQualities(readSeq, record.qual);
        if (hasFlagRC(record))
            reverseComplement(readSeq);

        // Get tags in SAM format.
        assignTagsBamToSam(contextSAM.tags, record.tags);

        // Check if read sequence is already in the store.  If so get the ID, otherwise create new entries in the read
        // then read name and mate pair store.
        contextSAM.readId = 0;
        if (importFlags.importRead)
        {
            if (!importFlags.importReadName)
                clear(record.qName);

            bool newRead = _storeAppendRead(fragStore, contextSAM.readId, record.qName, readSeq, record.flag,
                                            contextSAM);
            (void)newRead;
            SEQAN_ASSERT_NOT(newRead && empty(readSeq));
        }

        // Stop if read is not aligned.
        if (record.rID == BamAlignmentRecord::INVALID_REFID || record.beginPos == BamAlignmentRecord::INVALID_POS)
            return;

        // Check if the contig is already in the store.  Get its ID or create a new one otherwise.
        contextSAM.contigId = 0;
        _storeAppendContig(fragStore, contextSAM.contigId, nameStore(bamIOContext)[record.rID]);
        resize(fragStore.contigStore, length(fragStore.contigNameStore));

        // Stop if no alignment in CIGAR string.
        if (empty(record.cigar))
            return;

        // Handle read alignment import.
        TId pairMatchId = 0;
        if (importFlags.importReadAlignment)
        {
            // generate gap anchor string for the read
            if (importFlags.importReadSeq)
                _samAppendAlignment(fragStore, fragStore.readSeqStore[contextSAM.readId], record.cigar, beginPos, endPos,
                                    pairMatchId, contextSAM);
            else
                _samAppendAlignmentWithoutSeq(fragStore, record.cigar, beginPos, endPos, pairMatchId, contextSAM);

            clear(contextSAM.contigGapAnchors);
            TContigGapsPW contigGaps(contextSAM.contigGapAnchors);
            cigarToGapAnchorContig(record.cigar, contigGaps);
            appendValue(contigAnchorGaps, contextSAM.contigGapAnchors);
        }

        // Import tags and remove some tags.
        if (importFlags.importReadAlignmentTags || importFlags.importReadAlignmentQuality)
        {
            // extract and delete some tags
            if (!empty(contextSAM.tags))
                for (unsigned pos = length(contextSAM.tags), right = length(contextSAM.tags); pos != 0; )
                {
                    --pos;
                    if (pos == 0 || contextSAM.tags[pos] == '\t')
                    {
                        unsigned left = pos;
                        if (contextSAM.tags[left] == '\t') ++left;

                        bool remove = false;
                        if (infix(contextSAM.tags, left, left + 2) == "MD")
                            remove = true;

                        if (infix(contextSAM.tags, left, left + 2) == "NM")
                        {
                            int errors = lexicalCast<int>(infix(contextSAM.tags, left + 5, right));  // NM:i:x
                            mapQ.errors = errors;
                            remove = true;
                        }

                        if (remove)
                            erase(contextSAM.tags, left, _min(right + 1, length(contextSAM.tags)));

                        right = pos;
                    }
                }
        }

        // Create entries in Sam specific stores.
        if (importFlags.importReadAlignmentQuality)
            appendValue(fragStore.alignQualityStore, mapQ, Generous());

        if (importFlags.importReadAlignmentTags)
            appendValue(fragStore.alignedReadTagStore, contextSAM.tags, Generous());

        // Store additional data about match mate temporarily.
        // used in the end of the read function to generate match mate IDs.
        if (importFlags.importRead && importFlags.importReadAlignment && record.rNextId != BamAlignmentRecord::INVALID_REFID)
        {
            TId mcontigId = contextSAM.contigId;
            if (record.rID != record.rNextId)
            {
                _storeAppendContig(fragStore, mcontigId, nameStore(bamIOContext)[record.rNextId]);
                resize(fragStore.contigStore, length(fragStore.contigNameStore));
            }

            if (contextSAM.readId < length(fragStore.readStore))
            {
                // insert match mate info for the mate record
                TMatchMateInfo matchMateInfo =
                {
                    /* .readId      = */  contextSAM.readId,
                    /* .contigId    = */  mcontigId,
                    /* .pairMatchId = */  pairMatchId,
                    /* .matePairId  = */  fragStore.readStore[contextSAM.readId].matePairId,
                    /* .beginPos    = */  record.pNext,
                    /* .reversed    = */  hasFlagNextRC(record)
                };
                appendValue(matchMateInfos, matchMateInfo);
                back(fragStore.alignedReadStore).pairMatchId = pairMatchId;
            }
        }
    }

//////////////////////////////////////////////////////////////////////////////
// write functions for Sam
//////////////////////////////////////////////////////////////////////////////

// --------------------------------------------------------------------------
// Function _fillHeader()
// --------------------------------------------------------------------------

template <typename TSpec, typename TConfig>
inline void
_fillHeader(BamHeader & header,
            FragmentStore<TSpec, TConfig> & store)
{
    typedef FragmentStore<TSpec, TConfig>                       TFragmentStore;
    typedef typename TFragmentStore::TLibraryStore              TLibraryStore;
    typedef typename TFragmentStore::TContigStore               TContigStore;
    typedef typename TFragmentStore::TNameStore                 TNameStore;

    typedef typename Value<TContigStore>::Type                  TContig;
    typedef typename Iterator<TLibraryStore, Standard>::Type    TLibraryIter;
    typedef typename Iterator<TContigStore, Standard>::Type     TContigIter;
    typedef typename Iterator<TNameStore, Standard>::Type       TContigNameIter;
    typedef typename Id<TContig>::Type                          TId;

    typedef BamHeader::TSequenceInfo                            TSequenceInfo;
    typedef BamHeaderRecord::TTag                               TTag;

    // Fill first header line.
    BamHeaderRecord firstRecord;
    firstRecord.type = BAM_HEADER_FIRST;
    appendValue(firstRecord.tags, TTag("VN", "1.4"));
    appendValue(firstRecord.tags, TTag("SO", "unsorted"));
    appendValue(header.records, firstRecord);

    // Fill sequence info header line.
    TContigIter it          = begin(store.contigStore, Standard());
    TContigIter itEnd       = end(store.contigStore, Standard());
    TContigNameIter nit     = begin(store.contigNameStore, Standard());
    TContigNameIter nitEnd  = end(store.contigNameStore, Standard());

    for (; it != itEnd && nit != nitEnd; ++it, ++nit)
        appendValue(header.sequenceInfos, TSequenceInfo(*nit, length((*it).seq)));

    // Fill program header line.
    BamHeaderRecord pgRecord;
    pgRecord.type = BAM_HEADER_PROGRAM;
    appendValue(pgRecord.tags, TTag("ID", "SeqAn"));
    appendValue(header.records, pgRecord);

    // Fill library info header line.
    BamHeaderRecord rgRecord;
    rgRecord.type = BAM_HEADER_READ_GROUP;

    TLibraryIter lit    = begin(store.libraryStore, Standard());
    TLibraryIter litEnd = end(store.libraryStore, Standard());

    for (TId id = 0; lit != litEnd; ++lit, ++id)
    {
        appendValue(pgRecord.tags, TTag("ID", id + 1));
        appendValue(pgRecord.tags, TTag("LB", store.libraryNameStore[id]));
        appendValue(pgRecord.tags, TTag("PI", (int)store.libraryStore[id].mean));
        // Sample name needs to be included into fragment store.
        appendValue(pgRecord.tags, TTag("SM", "none"));
    }
}

// --------------------------------------------------------------------------
// Function _writeHeader()
// --------------------------------------------------------------------------

template <typename TStream, typename TSpec, typename TConfig, typename TContext>
inline void _writeHeader(TStream & target,
                         FragmentStore<TSpec, TConfig> & store,
                         TContext & context,
                         Sam)
{
    BamHeader header;

    // Fill header with information from fragment store.
    _fillHeader(header, store);

    // Write header to target.
    write2(target, header, context, Sam());
}

// --------------------------------------------------------------------------
// Function _fillBamSeqAndQual()
// --------------------------------------------------------------------------
template <typename TSeq, typename TQual, typename TRead>
inline void
_fillBamSeqAndQual(TSeq &bamSeq, TQual &bamQual, TRead const &read)
{
    bamSeq = read;

    resize(bamQual, length(read));
    typename Iterator<TQual, Standard>::Type       tIt    = begin(bamQual, Standard());
    typename Iterator<TRead const, Standard>::Type sIt    = begin(read, Standard());
    typename Iterator<TRead const, Standard>::Type sItEnd = end(read, Standard());

    for (; sIt != sItEnd; ++sIt, ++tIt)
        *tIt = (char)(getQualityValue(*sIt) + '!');
}

// --------------------------------------------------------------------------
// Function _fillRecord()
// --------------------------------------------------------------------------

template <typename TSpec, typename TConfig, typename TAlignedRead, typename TAlignQuality, typename TAlignFunctor>
inline void
setPrimaryMatch(BamAlignmentRecord & record,
                FragmentStore<TSpec, TConfig> & store,
                TAlignedRead const & alignedRead,       // read alignment to transform into a BamAlignmentRecord
                TAlignQuality const & alignQuality,     // read alignment quality
                TAlignFunctor & alignFunctor,           // functor that extracts/computes alignment for cigar/md strings
                bool secondaryAlignment)                // is this a secondary alignment?
{
    typedef FragmentStore<TSpec, TConfig>                           TFragmentStore;

    typedef typename TFragmentStore::TContigStore                   TContigStore;
    typedef typename Value<TContigStore>::Type                      TContig;
    typedef typename TContig::TGapAnchors                           TContigGapAnchors;

    typedef Iterator<CharString, Standard>::Type                    TCharStringIterator;

    typedef Gaps<Nothing, AnchorGaps<TContigGapAnchors> >           TContigGaps;

    // Fill QNAME with read name.
    clear(record.qName);
    TCharStringIterator it = begin(store.readNameStore[alignedRead.readId], Standard());
    TCharStringIterator itEnd = end(store.readNameStore[alignedRead.readId], Standard());
    for (; it != itEnd && *it != ' ' && *it != '\t'; ++it)
        appendValue(record.qName, *it);

    // Fill FLAG.
    unsigned short flag = 0;

    if (alignedRead.beginPos > alignedRead.endPos)
        flag |= BAM_FLAG_RC;
    if (secondaryAlignment)
        flag |= BAM_FLAG_SECONDARY;     // we've already output an alignment for this read (this one is secondary)

    signed char mateNo = getMateNo(store, alignedRead.readId);
    if (mateNo == 0)
        flag |= BAM_FLAG_FIRST;        // this read is the first in the pair
    else if (mateNo == 1)
        flag |= BAM_FLAG_LAST;         // this read is the second in the pair

    // Set flags regarding mate alignment.

    // We disinguish 3 cases:
    //  1) We have no mate (single-end read)
    //  2) We might have a mate, but it wasn't aligned properly
    //  3) We have a mate which was aligned properly
    //
    // wich are encoded as follows:
    //  1) alignedRead and alignedMate have the same address in _fillRecord
    //  2) alignedMate has an invalid contigId (== INVALID_ID)
    //  3) alignedRead and alignedMate have valid readIds

    if (mateNo >= 0)
        flag |=   BAM_FLAG_MULTIPLE | BAM_FLAG_NEXT_UNMAPPED;   // there is a mate
    else
        flag &= ~(BAM_FLAG_MULTIPLE | BAM_FLAG_NEXT_UNMAPPED);  // there is no mate

    record.flag = flag;

    // Fill RNAME by providing contig id.
    record.rID = alignedRead.contigId;

    // Fill POS with start position.
    TContigGaps contigGaps(/*store.contigStore[alignedRead.contigId].seq, */store.contigStore[alignedRead.contigId].gaps);
    record.beginPos = positionGapToSeq(contigGaps, std::min(alignedRead.beginPos, alignedRead.endPos));

    // Fill MAPQ with mapping quality.
//    if (alignQuality.score != TAlignedReadQualityElement::INVALID_SCORE)
    if (alignQuality.score > 0)
        record.mapQ = alignQuality.score;
    else
        record.mapQ = 255;

//    // Fill CIGAR using aligned read.
//    if (!IsSameType<TAlignFunctor, Nothing>::VALUE)
//        getCigarString(record.cigar, row(align, 0), row(align, 1));

    // Retrieve number of errors from quality store.
    int errors = -1;
    if (alignQuality.errors != MaxValue<unsigned char>::VALUE)
        errors = alignQuality.errors;

    // Use record.qual as a temporary for the md string.
    alignAndGetCigarString(record.cigar, record.qual, store.contigStore[alignedRead.contigId],
            store.readSeqStore[alignedRead.readId], alignedRead, errors, alignFunctor);

    if (alignQuality.errors != MaxValue<unsigned char>::VALUE)
    {
//        if (errors > (int)alignQuality.errors)
//            std::cerr << "WARNING: More errors in the alignment (" << errors << ") than given in NM tag / alignQuality ("
//                      << (int)alignQuality.errors << ") for read " << record.qName << std::endl;

        // To output the same NM value if a SAM file is loaded and saved, we overwrite error with the original value
        // TODO(weese): This can be changed if desired (uncomment the following line) but now even the ex1.sam example
        //              of the SAMtools have NM values that are inconsistent to their CIGAR/MD strings
        errors = alignQuality.errors;
    }

    // Fill tags here to release record.qual
    clear(record.tags);
    if (errors != -1)
        appendTagValue(record.tags, "NM", errors);
    if (!empty(record.tags))
        appendTagValue(record.tags, "MD", record.qual, 'Z');

    record.rNextId = BamAlignmentRecord::INVALID_REFID;
    record.pNext = BamAlignmentRecord::INVALID_POS;
    record.tLen = BamAlignmentRecord::INVALID_LEN;

    if (!secondaryAlignment)
    {
        // Fill SEQ and QUAL with read sequence and quality values.
        if (alignedRead.beginPos <= alignedRead.endPos)
            _fillBamSeqAndQual(record.seq, record.qual, store.readSeqStore[alignedRead.readId]);
        else
            _fillBamSeqAndQual(record.seq, record.qual, reverseComplementString(store.readSeqStore[alignedRead.readId]));
    }
    else
    {
        clear(record.seq);
        clear(record.qual);
    }
}

template <typename TSpec, typename TConfig, typename TAlignedRead>
inline void
setMateMatch(BamAlignmentRecord & record,
            FragmentStore<TSpec, TConfig> & store,
            TAlignedRead const & alignedRead,       // read alignment to transform into a BamAlignmentRecord
            TAlignedRead const & alignedMate)       // alignment of the mate
{
    typedef FragmentStore<TSpec, TConfig>                           TFragmentStore;

    typedef typename TFragmentStore::TContigStore                   TContigStore;
    typedef typename Value<TContigStore>::Type                      TContig;
    typedef typename TContig::TGapAnchors                           TContigGapAnchors;

    typedef typename TFragmentStore::TReadStore                     TReadStore;
    typedef typename Value<TReadStore>::Type                        TReadStoreElement;

    typedef Gaps<Nothing, AnchorGaps<TContigGapAnchors> >           TContigGaps;

    record.flag &= ~(BAM_FLAG_ALL_PROPER | BAM_FLAG_NEXT_RC | BAM_FLAG_NEXT_UNMAPPED);
    if (alignedMate.contigId != TReadStoreElement::INVALID_ID)
    {
        record.flag |= BAM_FLAG_ALL_PROPER;    // mate is mapped properly

        if (alignedMate.beginPos > alignedMate.endPos)
            record.flag |= BAM_FLAG_NEXT_RC;   // mate is mapped on reverse strand
    }
    else
    {
        record.flag |= BAM_FLAG_NEXT_UNMAPPED; // mate is unmapped
    }

    record.rNextId = (alignedMate.contigId != TContig::INVALID_ID)? alignedMate.contigId : BamAlignmentRecord::INVALID_REFID;

    // Fill PNEXT with mate start position
    // Fill TLEN with outer distance of the read alignments
    if (alignedMate.contigId < length(store.contigStore))
    {
        TContigGaps contigGaps(store.contigStore[alignedMate.contigId].gaps);
        record.pNext = positionGapToSeq(contigGaps, std::min(alignedMate.beginPos, alignedMate.endPos));

        if (alignedMate.contigId == alignedRead.contigId)
        {
            if (alignedRead.beginPos < alignedMate.beginPos)
                record.tLen = positionGapToSeq(contigGaps, std::max(alignedMate.beginPos, alignedMate.endPos) - 1) - record.beginPos + 1;
            else
                record.tLen = record.pNext - positionGapToSeq(contigGaps, std::max(alignedRead.beginPos, alignedRead.endPos) - 1) - 1;
        }
        else
        {
            record.tLen = BamAlignmentRecord::INVALID_LEN;
        }
    }
    else
    {
        record.pNext = BamAlignmentRecord::INVALID_POS;
        record.tLen = BamAlignmentRecord::INVALID_LEN;
    }
}

// --------------------------------------------------------------------------
// Function _writeAlignedReads()
// --------------------------------------------------------------------------

template <typename TStream, typename TSpec, typename TConfig, typename TContext, typename TAlignFunctor>
inline void _writeAlignedReads(
    TStream & target,
    FragmentStore<TSpec, TConfig> & store,
    TContext & context,
    TAlignFunctor & alignFunctor,
    Sam)
{
    typedef FragmentStore<TSpec, TConfig>                           TFragmentStore;

    typedef typename TFragmentStore::TReadStore                     TReadStore;
    typedef typename Value<TReadStore>::Type                        TReadStoreElement;

    typedef typename TFragmentStore::TAlignedReadStore              TAlignedReadStore;
    typedef typename Iterator<TAlignedReadStore, Standard>::Type    TAlignedReadStoreIterator;
    typedef typename Value<TAlignedReadStore>::Type                 TAlignedReadStoreElement;
    typedef typename Id<TAlignedReadStoreElement>::Type             TAlignedReadStoreElementId;

    typedef typename TFragmentStore::TAlignQualityStore             TAlignQualityStore;
    typedef typename Value<TAlignQualityStore>::Type                TAlignQualityStoreElement;

    typedef TAlignQualityStoreElement *                             TAlignQualityStoreElementPtr;

    // Store outer library size for each pair match (indexed by pairMatchId)
    String<TAlignedReadStoreElementId> mateIndices;
    calculateMateIndices(mateIndices, store);

    // Bitset to signal wether a read was aligned at least once.
    String<bool, Packed<> > readAligned;
    resize(readAligned, length(store.readStore), false);

    // Dummy store elements to cope with missing information.
    TAlignQualityStoreElement       noAlignQuality;
    TAlignQualityStoreElementPtr    alignQualityPtr;

    TAlignedReadStoreIterator it    = begin(store.alignedReadStore, Standard());
    TAlignedReadStoreIterator itEnd = end(store.alignedReadStore, Standard());

    BamAlignmentRecord record;

    for (; it != itEnd; ++it)
    {
        TAlignedReadStoreElement &alignedRead = *it;

        // Try to get quality.
        if (alignedRead.id < length(store.alignQualityStore))
            alignQualityPtr = &store.alignQualityStore[alignedRead.id];
        else
            alignQualityPtr = &noAlignQuality;

        // Try to get a mate.

        // We disinguish 3 cases:
        //  1) We have no mate (single-end read)
        //  2) We might have a mate, but it wasn't aligned properly
        //  3) We have a mate which was aligned properly

        // Test for secondary alignment and mark read as seen.
        bool secondary = getValue(readAligned, alignedRead.readId);
        assignValue(readAligned, alignedRead.readId, true);

        // Fill record.
        clear(record);

        // case 1 or 2 is handled here
        setPrimaryMatch(record, store, alignedRead, *alignQualityPtr, alignFunctor, secondary);

        if (alignedRead.pairMatchId != TReadStoreElement::INVALID_ID)
        {
            // case 3
            TAlignedReadStoreElementId mateIndex = mateIndices[2 * alignedRead.pairMatchId + getMateNo(store, alignedRead.readId)];
            if (mateIndex < length(store.alignedReadStore))
                setMateMatch(record, store, alignedRead, store.alignedReadStore[mateIndex]);
        }

        // Append additional tags.
        if (alignedRead.id < length(store.alignedReadTagStore))
            assignTagsSamToBam(record.tags, store.alignedReadTagStore[alignedRead.id]);

        // Write record to target.
        write2(target, record, context, Sam());
    }
}

//////////////////////////////////////////////////////////////////////////////
// write

///.Function.write.param.tag.type:Tag.File Format.tag.Sam

    template<typename TFile, typename TSpec, typename TConfig, typename TAlignFunctor>
    inline void write(TFile & target,
                      FragmentStore<TSpec, TConfig> & store,
                      TAlignFunctor & alignFunctor,
                      Sam)
    {
        typedef FragmentStore<TSpec, TConfig>               TFragmentStore;
        typedef typename TFragmentStore::TContigNameStore   TContigNameStore;
        typedef BamIOContext<TContigNameStore>              TBamIOContext;

        TBamIOContext context(store.contigNameStore, store.contigNameStoreCache);

        // 1. write header
        _writeHeader(target, store, context, Sam());

        // 2. write aligments
        _writeAlignedReads(target, store, context, alignFunctor, Sam());
    }

    template<typename TFile, typename TSpec, typename TConfig>
    inline void write(TFile & target,
                      FragmentStore<TSpec, TConfig> & store,
                      Sam)
    {
        BamAlignFunctorDefault alignFunctor;
        write(target, store, alignFunctor, Sam());
    }

}// namespace SEQAN_NAMESPACE_MAIN

#endif //#ifndef SEQAN_HEADER_...


TEMPUR UK advises how to achieve quality sleep during longer daylight hours.
Many of us will be enjoying the longer, warmer days now that summer is well and truly upon us.
The flipside of the longer daylight hours is that many also struggle to settle children at bedtime, find it difficult to doze off during lighter evenings or are woken way too early by sunlight streaming through the bedroom windows.
As we approach the Summer Solstice on Thursday 21 June – the longest day of the year and the shortest for hours of darkness – premium mattress brand, TEMPUR, is on hand to provide tips for getting a decent night's rest despite the lighter evenings and mornings.
Light is one of the most important external factors that affect sleep. It can change the body's physiological state, encouraging alertness and energy rather than relaxation when we're trying to drift off.
Disrupting the body's internal "body clock" in this way alters the sleep-wake cycle, interfering with both quality and quantity of sleep by causing frequent or prolonged wakefulness.
At the more extreme end, a disrupted body clock can lead to slower response time, compromised well-being, or even depression. In short, poor sleep can make us ill.
Body clocks are inherently biological, meaning they cannot be changed easily or quickly. People are generally divided into night owls (those who go to bed later and rise later) or early birds (going to bed earlier and waking earlier). There are ways, however, to manage the natural cycle and ensure sleep is of the highest possible quality.
The optimal sleep environment should mimic a cave: dark, quiet, cool and comfortable.
Curtains and blinds keep outside light from disturbing your sleep. Make sure window coverings are heavy enough to fully block light and are well fitted to avoid slivers of the streetlight or early morning sunlight from filtering in. Blackout curtains are designed to provide this kind of thorough protection against unwanted light. If you have blinds, combine with curtains to avoid light getting in around the edges.
Stick to a routine, as the body needs time to prepare for sleep. It can be tempting to stay awake later as daylight hours lengthen, but the brain thrives on routine, so stick to bedtimes for children and use a sleep routine that includes a gradually darkening environment.
Dim the lights a full hour before bedtime to encourage your body to begin its physiological progression toward sleep. Use a dimmer switch on overhead lights to control their brightness, or install low-watt, dimmable bulbs in lamps.
Avoid screen time the hour before bed: turn off the television, power down computers and tablets, and put your phone away for the night. The light from digital devices contains high concentrations of blue light, a wavelength of light that research has shown is especially detrimental to sleep.
Turn on 'sleep mode', switch off devices entirely or remove them from the room if possible. Try using a traditional alarm clock in place of a phone alarm.
Keep doors closed to prevent chinks of light entering from the hallway or other rooms, and if necessary, use nightlights with a red bulb for low-level light.
An eye mask worn at night can help deepen darkness and protect against intrusive light. Choose a mask that is soft, comfortable, and flexible. Wearing an eye mask can take a little getting used to, but it is a highly effective tool for limiting your light exposure at night.
The bedroom décor can be important too. Choose dark bedroom wall paint or paper as these won't reflect the light.


text:
MARIO VARGAS LLOSA The Dream of the Celt. Reviewed by Peter Corris
Posted by The Newtown Review of Books in Fiction
Amazonia, Congo, Ireland, Roger Casement, rubber, slavery
The strange case of Roger Casement.
The ghost of Roger Casement is beating on the door. W B Yeats
This a difficult book to review, but not because it's boring or poorly written – I read it comparatively quickly with great interest – but because it is more like a biography than a novel and is not quite satisfactory as either. In part, this may be a characteristic of the Latin American novel, or the fault of the translator, but only in part.
At various points the author seems to forget he is writing a story, dramatising events, and includes large chunks of undigested factual material. For example, the information on the career of Henry Morton Stanley reads as if lifted from an encyclopaedia. At times basic conventions of fiction are violated: characters speak at such inordinate length the listener would be looking for the door.
I found myself constantly wishing for documentary support for the text – footnotes, even – which is no way to evaluate a novel.
That said, the life of Roger Casement, even if under-dramatised here, is of compelling interest and Llosa has traced its tragic course from his childhood in Victorian Ireland to his execution in an English prison in 1916 at the age of fifty-one. Casement's career was a mixture of idealism, persistence amounting to heroism – as he endured severe privation and danger while investigating atrocities on rubber plantations in the Belgian Congo and Peru – and extraordinary foolishness.
He was undoubtedly a complex character – he went from being an ardent imperialist to a passionate anti-colonialist and Irish nationalist. From being a lukewarm Anglican, Casement became a convinced Catholic with mystical leanings. His sexuality was, to put it mildly, unusual. Discovering his homosexual urges early, he subsumed them by photographing young men and remained a virgin until well into his twenties. When he finally overcame his self-disgust and had sex, it was as a cruiser of beats in foreign places. That in itself is not unusual, but Casement, in the notorious 'black diaries', documented not only his actual and infrequent sexual experiences but also the fantasies about those he wished he had, or had only observed in voyeuristic fashion.
In short, the book, for all its length and detail, does not fully realise its subject. Casement's attitudes and feelings are stated rather than shown, and the result is a character toned down, like the sepia photographs of the period. Llosa's treatment of his subject's sexual history is cool to the point of detachment, and this is not the only lapse. Casement, we learn, was a heavy smoker, but in the long and detailed account of his time in prison smoking is not mentioned. Did he smoke or not? And if not, surely he would have suffered. Llosa's treatment of sex and smoking represent missed opportunities to dramatise his material.
He is much better on Casement's absurd plan to collaborate with Germany during World War I to foment and achieve successful rebellion in Ireland. As the plan unravels, Llosa depicts Casement as tortured by the thought that this scheme had been a mistake and would delay rather than advance a push for Irish independence. In Germany, Casement comes close to physical and spiritual disintegration as the depth of his naiveté is brought home to him and here the writing sings. It should have sung more often – in the Congo and Amazon jungles and in the depictions of Roger Casement's sad inner world.
Mario Vargas Llosa The Dream of the Celt, Faber, 2012, PB, 400pp, $29.99.
To order this book from Better Read Than Dead at 10% discount, click here.

redpajama_set_name: RedPajamaCommonCrawl


text:
\section{Introduction}
Since the discovery of high temperature superconductors
 and the related insulating materials,
 there has been a lot of interest in
 two-dimensional spin-$\frac{1}{2}$ magnetic
 or antiferromagnetically correlated electron systems.\cite{young,manousakis}
However not much attention has been paid to the magnetic
 properties of these systems
 coupled to an external magnetic field.\cite{bagehorn,held,scalapino}
The original Harper's equation \cite{hofstadter,macdonald,hasegawa}
 is concerned with the energy dispersion
 involving the systems of noninteracting electrons
 under the magnetic field.
Hence it is of great interest to study
 how the systems of interacting
 (antiferromagnetically correlated) electrons behave
 under an external magnetic field.
We derive a generalized Harper's equation
 which describes the dispersion of
 antiferromagnetically correlated  electrons
 under the applied magnetic field.
Earlier we paid attention to the dispersion of
 the antiferromagnetically correlated electrons
 only at half filling (and thus with no doping)
 and at zero temperature,
 by considering the square lattice of finite size.\cite{doh}
On the other hand,
 in the present study
 we derive a generalized Harper's equation
 for the square lattice of the infinite size,
 and examine the dispersion relation
 as a function of temperature and doping rate.
An analytic expression for the density of states is obtained
 from the generalized Harper's equation
 for the system of antiferromagnetically correlated electrons.
We present a phase diagram of staggered magnetization
 in the plane of temperature vs doping rate
 and find the hitherto-unnoticed reentrant behavior
 of the staggered magnetization
 even in the presence of external magnetic field.
Finally it is shown that
 below a critical electron correlation strength
 the staggered magnetization disappears
 at an even denominator value of $q$ but not at odd $q$
 of a given magnetic flux quantum per plaquette, $p/q$.

\section{Generalized Harper's Equation and Density of States}
We write the Hubbard model Hamiltonian
 describing the two-dimensional system
 of antiferromagnetically correlated electrons
 under an external magnetic field,\cite{hasegawa}

\begin{equation}
 H = -t \sum_{\langle ij\rangle\sigma}
  \left[
  \exp\left(-i\frac{2\pi}{\phi_0}\int_j^i {\bf A}\cdot d \bbox{\ell}\right)
  c_{i\sigma}^\dag c_{j\sigma}^{}
  + \mbox{H.c.} \right]
  + U \sum_i n_{i\uparrow}^{} n_{i\downarrow}^{}
  - \mu \sum_{i\sigma} c_{i\sigma}^\dag c_{i\sigma}^{}~~,
\end{equation}

\noindent
 where $t$ is the hopping integral;
 ${\bf A}$, the electromagnetic vector potential;
 $\phi_0=\frac{hc}{e}$, the elementary flux quantum;
 $U$, the on-site Coulomb repulsion energy,
 and $\mu$, the chemical potential.
$\langle ij\rangle$ stands for summation
 over nearest neighbor sites $i$ and $j$.
$c_{i\sigma}^\dag$ ($c_{i\sigma}^{}$)
 is the creation (annihilation) operator of an electron of
 spin $\sigma$ at site $i$,
 and $n_{i\uparrow}^{}$ ($n_{i\downarrow}^{}$), the number operator of
 an up-spin (down-spin) electron at site $i$.

The staggered magnetization (antiferromagnetic order)
 at site $i$ is written as
 $m_i =  e^{i{\bf Q}\cdot{\bf r}_i}
 \sum_\sigma \sigma \langle c_{i\sigma}^\dag c_{i\sigma}^{} \rangle$,
 where ${\bf Q}=(\pi,\pi)$
 and ${\bf r}_i=(i_x,i_y)$ with $i_x$ and $i_y$ being integers
 with the lattice spacing of unity.
Introducing
 a uniform staggered magnetization $m$
 and a uniform doping rate $\delta$, i.e.,
\addtocounter{equation}{1}
\newcounter{uniform}
\setcounter{uniform}{\arabic{equation}}
$$
 m = \frac{1}{N} \sum_{i\sigma} e^{i{\bf Q}\cdot{\bf r}_i}
     \sigma \langle c_{i\sigma}^\dag c_{i\sigma}^{} \rangle ~~,
 \eqno{(\arabic{uniform}a)}
$$
$$
 \delta = 1 - \frac{1}{N} \sum_{i}
          \langle n_i^{} \rangle ~~,
 \eqno{(\arabic{uniform}b)}
$$
 with the number of lattice sites $N$,
 and using the Landau gauge ${\bf A}=B(0,x,0)$,
 we obtain the mean field (Hartree-Fock) Hamiltonian
 in the momentum space,
\begin{eqnarray}
 H &=& -t \sum_{{\bf k}\sigma}
  \left[2\cos k_x c_{{\bf k}\sigma}^\dag c_{{\bf k}\sigma}^{}
  + e^{-ik_y} c_{{\bf k}-{\bf g},\sigma}^\dag c_{{\bf k}\sigma}^{}
  + e^{ik_y} c_{{\bf k}+{\bf g},\sigma}^\dag c_{{\bf k}\sigma}^{}\right]
 \nonumber \\
 && -\frac{mU}{2}\sum_{{\bf k}\sigma} \sigma
  c_{{\bf k}+{\bf Q},\sigma}^\dag c_{{\bf k}\sigma}^{}
  + [\frac{U}{2}(1-\delta)-\mu] \sum_{{\bf k}\sigma}
  c_{{\bf k}\sigma}^\dag c_{{\bf k}\sigma}^{}~~,
\label{hammag}
\end{eqnarray}
 where
 ${\bf g}\equiv \left(2\pi\frac{\phi}{\phi_0},0\right) = \left(2\pi\frac{p}{q},0\right)$
 with $\frac{p}{q}$, the number of flux quanta per plaquette.
The first bracketed term in (\ref{hammag}) represents hopping processes;
 the first term in the bracket
 represents the nearest neighbor hopping in the $x$-direction
 and the last two terms in the bracket,
 the nearest neighbor hopping in the $y$-direction.
Because of the choice of the Landau gauge ${\bf A}=B(0,x,0)$,
 the electron acquires no phase when it hops in the $x$-direction,
 while it acquires a phase when it hops in the $y$-direction,
 and the electromagnetic vector potential ${\bf A}$
 shifts the wave vector of electron in the $k_x$-direction
 by $g \equiv |{\bf g}|=2\pi\frac{p}{q}$.
The second term results from the nature of
 the antiferromagnetic spin order of correlated electrons,
 which causes the wave vector to shift by ${\bf Q}$.
The last term represents energy shift by $\frac{U}{2}(1-\delta)$
 as a result of hole doping.

The Hamiltonian (\ref{hammag}) can be written as
$$
H = H_0 + H_1 ~,
$$
$$
 H_0 = [\frac{U}{2}(1-\delta)-\mu] \sum_{{\bf k}\sigma}
  c_{{\bf k}\sigma}^\dag c_{{\bf k}\sigma}^{}~~,
$$
\addtocounter{equation}{1}
\newcounter{Hks}
\setcounter{Hks}{\arabic{equation}}
$$
 H_1 = \sum'_{{\bf k}\sigma}
 {\bf C}^\dag_{k\sigma} {\bf H}_{k\sigma} {\bf C}_{k\sigma} ~,
\eqno{(\arabic{equation}a)}
$$
where
$$
{\bf C}_{k\sigma} =
        \left[ \begin{array}{c}
         c_{{\bf k}+{\bf g},\sigma} \\
         \vdots \\[-2mm]
         c_{{\bf k}+(q-1){\bf g},\sigma} \\
         c_{{\bf k}\sigma} \\
         \hline
         c_{{\bf k}+{\bf g}+{\bf Q},\sigma} \\
         \vdots \\[-2mm]
         c_{{\bf k}+(q-1){\bf g}+{\bf Q},\sigma} \\
         c_{{\bf k}+{\bf Q},\sigma}
        \end{array} \right] ~,
\eqno{(\arabic{equation}b)}
$$
$$
  {\bf H}_{k\sigma} = \left[ \begin{array}{c|c} {\bf T}_k & {\bf V}_\sigma \\ \hline {\bf V}_\sigma & -{\bf T}_k \end{array} \right] ~,
\eqno{(\arabic{equation}c)}
$$
$$
 {\bf T}_k = -t\left[ \begin{array}{ccccc}
  M_1        & e^{-ik_y} & 0      & 0          & e^{ik_y}  \\
  e^{ik_y}   & M_2       & \ddots & 0          & 0          \\
  0          & \ddots    & \ddots & \ddots     & 0          \\
  0          & 0         & \ddots & M_{q-1}    & e^{-ik_y} \\
  e^{-ik_y}  & 0          & 0     & e^{ik_y}   & M_q
 \end{array} \right] ~,
\eqno{(\arabic{equation}d)}
$$
and
$$
 {\bf V}_\sigma = \left[ \begin{array}{ccccc}
 -\frac{\sigma mU}{2} & 0     & 0      & 0     & 0     \\
 0     & -\frac{\sigma mU}{2} & 0      & 0     & 0     \\
 0     & 0     & \ddots & 0     & 0     \\
 0     & 0     & 0      & -\frac{\sigma mU}{2} & 0     \\
 0     & 0     & 0      & 0     & -\frac{\sigma mU}{2}
 \end{array} \right]
\eqno{(\arabic{equation}e)}
$$
with $M_n = 2\cos(k_x+ng)$.
The summation $\sum'_{{\bf k}}$ is
 over the reduced Brillouin zone,
 $\{(k_x, k_y) | -\frac{\pi}{q}\le k_x \le\frac{\pi}{q},
 ~~ -\frac{\pi}{2} \le k_y \le \frac{\pi}{2} \}$.
The Brillouin zone is reduced by $1/q$
 because there exist $q$ plaquettes per magnetic unit cell,
 and is further reduced by $1/2$
 as a result of staggered magnetization (or antiferromagnetic order).
The diagonal matrix ${\bf T}_k$ is associated with electron hopping
 and contains information on the phase modulation
 of hopping electrons under the influence of the external field.
The off-diagonal matrix ${\bf V_\sigma}$ represents
 the antiferromagnetic electron correlation.

From the eigenvalue equation of the Hamiltonian matrix ${\bf H}_{k\sigma}$
 with the identity matrix ${\bf I}$,
\begin{equation}
 \det({\bf H}_{k\sigma} -E_k {\bf I}) = 0 ~~,
\label{genhar}
\end{equation}
 we obtain the quasiparticle energy dispersion $E_k$ of
 antiferromagnetically correlated electrons
 in the presence of magnetic field.
In the limiting case of noninteracting electrons ($U=0$)
 the `generalized' Harper's equation (\ref{genhar}) above
 is reduced to the original Harper's equation
 derived by Hasegawa et al.\cite{hasegawa}, that is,
\begin{equation}
 \det({\bf T}_{k} - \varepsilon_k {\bf I}) = 0 ~~,
 \label{harper}
\end{equation}
 where $\varepsilon_k$ is the energy dispersion of
 noninteracting electrons in the presence of magnetic field.
Following Hasegawa et al.\cite{hasegawa},
 Eq. (\ref{harper}) can be rewritten in a further simplified form,
\begin{equation}
 \gamma (\varepsilon) = \cos(qk_x) +\cos(qk_y) ~~,
\end{equation}
 where $\gamma(\varepsilon)$ is given in Table \ref{harpertable}~
 for various values of $p/q$
 including Hasegawa et al.'s results.\cite{hasegawa}
Now for the case of antiferromagnetically correlated electrons
 we obtain from the diagonalization of
 the Hamiltonian matrix ${\bf H}_{k\sigma}$ in Eq. (\arabic{Hks}c) above,
\begin{equation}
 E_k = \sqrt{\varepsilon_k + \Delta^2} ~~,
 \label{Ek}
\end{equation}
 with the band gap, $2\Delta=mU$.
The band gap $2\Delta$ is seen to depend on
 the magnitude of both the staggered magnetization $m$ and
 the electron correlation strength (Coulomb repulsion) $U$.

The energy dispersion relation Eq. (\ref{Ek}) above leads to
 the density of states,
\begin{eqnarray}
 g(E) &=& 4 \int' \frac{d^2 k}{(2\pi)^2} \delta(E-E_k)
 \nonumber \\
 &=& \frac{2}{q\pi^2} \left| \frac{d\gamma(\varepsilon)}{d\varepsilon} \right|
 K\left( \sqrt{1-\left(\frac{\gamma(\varepsilon)}{2}\right)^2} \right)
 \left| \frac{E}{\varepsilon} \right| ~~,
 \label{gE}
\end{eqnarray}
where $|\varepsilon| = \sqrt{E^2 - \left(\frac{mU}{2}\right)^2}$
and $K$ is the complete elliptic integral of the first kind,\cite{economou}
\begin{eqnarray*}
 K(\alpha) =
 \int_0^{\frac{\pi}{2}} \frac{d\phi}{\sqrt{1-\alpha^2\sin^2\phi}} ~~.
\end{eqnarray*}
Eq. (\ref{gE}) above represents
 the density of states
 for the systems of correlated electrons
 in the presence of magnetic field.
In the limiting case of vanishing electron correlation, i.e., $U=0$,
 it becomes exact.
In Fig.~\ref{dos} we display
 the density of states with $U=0$
 predicted from the analytic expression of
 the density of states in Eq. (\ref{gE}).
Encouragingly the analytic result is
 in excellent agreement with
 the numerical results obtained by Hasegawa et al.\cite{hasegawa}
In the presence of magnetic field with the flux quanta per plaquette $p/q$,
 a single band splits into $q$ subbands.
This is analogous to the energy level splitting into
 Landau levels for electrons
 embedded in a continuum state under a magnetic field.

\section{Phase Diagram and Reentrant Behavior of Staggered Magnetization
 In Applied Magnetic Fields}
The staggered magnetization $m$ and the chemical potential $\mu$
 vary with both the temperature $T$ and the doping rate $\delta$;
 they are obtained from
 the following self-consistent mean field equations,
 which are derived from the use of Eqs. (\arabic{uniform}),
\addtocounter{equation}{1}
\newcounter{self}
\setcounter{self}{\arabic{equation}}
$$
 1 = \int dE \frac{g(E)}{4} \frac{U}{2E}
       \left[ \tanh \frac{E^{\scriptscriptstyle(+)}}{2T}
       - \tanh \frac{E^{\scriptscriptstyle(-)}}{2T} \right] ~~,
   \eqno{(\arabic{equation}a)} \\
$$
$$
 \delta = \int dE \frac{g(E)}{4}
       \left[ \tanh \frac{E^{\scriptscriptstyle(+)}}{2T}
       + \tanh \frac{E^{\scriptscriptstyle(-)}}{2T} \right] ~~,
   \eqno{(\arabic{equation}b)}
$$
where $E^{\scriptscriptstyle (\pm)} = \pm E + \frac{U}{2} (1-\delta) - \mu$.

We examine the dependence of
 staggered magnetization on the external magnetic field
 in the $T$-$\delta$ plane,\cite{hong}
 by numerically solving Eqs. (\arabic{self})
 for $m$ and $\mu$ at each temperature $T$ and doping rate $\delta$.
The phase diagram of the staggered magnetization
 in the $T$-$\delta$ plane is displayed
 in Fig.~\ref{boundary} for several values of $p/q$.
Interestingly we find that the reentrant behavior
 of the staggered magnetization appears
 even in the presence of the external magnetic field.
However, the reentrant behavior of staggered magnetization
 in the absence of magnetic field
 has earlier been discovered
 by other investigators.\cite{halvorsen,inaba,hafu}
Halvorsen et al.\cite{halvorsen} found the reentrant behavior
 using the Hubbard model
 within the self-consistent second-order
 weak $U$-perturbation treatment.
Their studies are limited to a narrow range with small $U$
 compared to our present approach
 which can deal with the entire range of $U$.
Recently Inaba et al.\cite{inaba} found
 a similar reentrant behavior
 using the $t$-$J$ Hamiltonian in the slave-boson representation.
However their studies refer to the case of a large $U$ limit
due to the use of the $t$-$J$ Hamiltonian.
Unlike our present study
 their studies above refer to
 the reentrant behavior in the absence of the external magnetic field.

We now investigate
 the reentrant behavior of the staggered magnetization in detail.
In Fig.~\ref{reentrance} we display the staggered magnetization
 $m$ at $p/q=1/2$ as a function of temperature $T$
 at various doping rates $\delta$.
At half filling ($\delta=0$)
 the staggered magnetization reaches a maximum value at zero temperature.
On the other hand, away from half filling ($\delta \neq 0$)
 the predicted staggered magnetization shows a maximum
 at a finite temperature.
Above this temperature the reentrant behavior of
 a paramagnetic state is predicted.
The cause of the reentrant behavior
 can be explained from the nesting property
 of the energy surface at saddle points.\cite{inaba,hong}
In Fig.~\ref{disurf} we display
 the variation of energy dispersion
 of the highest occupied subband
 with the external magnetic field (or $p/q$).
The saddle points in the Brillouin zone are denoted by
 black dots at the bottom of the graph.
The adjacent saddle points are separated
 by the well-defined nesting vector of ${\bf Q}/q$,
 by which the staggered magnetization is defined.
In Fig.~\ref{fermi}
 we display the variation of Fermi surface (thick solid lines)
 with the magnetic field
 at finite doping rates.
As the temperature increases,
 the Fermi surface tends to smear out,
 which causes increment in the number of nesting channels,
 and consequently the staggered magnetization arises.
As the temperature still increases,
 further smearing of the Fermi surface opens
 other channels than the nesting channels.
As a result the staggered magnetization
 will eventually disappear to allow transition
 to a paramagnetic state.
This feature is well depicted in Figs. \ref{boundary} and \ref{reentrance}.

\section{Staggered Magnetization at Zero temperature and at Half Filling
 In a Magnetic Field}
Now we investigate the staggered magnetization
 at half filling $\delta=0$ and at $T=0$K
 in a magnetic field.
The chemical potential is given by $\mu=\frac{U}{2}$,
 and Eq. (\arabic{self}b)
 is trivially identified since the right hand side of the equation
 becomes zero, thus satisfying the condition of half filling,
 that is, $\delta=0$ as it should be.
Eq. (\arabic{self}a) can be expressed as
\begin{equation}
  \frac{1}{U} =
  \int_{-\infty}^0 d\varepsilon \frac{g_0(\varepsilon)}{2}
  \frac{1}{\sqrt{\varepsilon^2+\left(\frac{mU}{2}\right)^2}}
  ~~.
 \label{Uc}
\end{equation}
Here $g_0(\varepsilon)$ is the density of states
 of noninteracting electrons in the presence of magnetic field.
It is easily obtained from Eq. (\ref{gE}).
Eq. (\ref{Uc}) is in a similar form to the gap equation
 that appears in the spin density wave theory
 of cuprate materials.\cite{schrieffer,dagotto94}
 We will use it for the determination of
 the staggered magnetization $m$
 for the system of interacting electrons
 (with correlation strength $U$)
 in the presence of magnetic field.
In Fig.~\ref{undulatory}
 the oscillatory staggered magnetization is displayed
 as a function of magnetic field (specifically $p/q$),
 for several chosen values of correlation strength $U$.
The solid lines are the results of
 self-consistent calculations for
 a $20\times 20$ finite square lattice.\cite{doh}
Various other symbols represent the results
 from the newly derived analytic relation (\ref{Uc}) above.
Encouragingly they are in good agreement
 with the self-consistent calculations
 for the finite size square lattice.

In the following
 we explain the oscillatory behavior of staggered magnetization
 observed in our earlier work.\cite{doh}
At even denominator values of $q$ in $p/q$
 the staggered magnetization
 is predicted to disappear
 (e.g., see the case of $p/q=1/2$).
This feature is well depicted in Fig. \ref{undulatory}.
We now define the critical electron correlation strength
 (Coulomb repulsion) $U_{p/q}$
 as a value below which
 the staggered magnetization vanishes, i.e., $m=0$.
The predicted staggered magnetization
 from Eq. (\ref{Uc}) vanishes
 at the even $q$ values
 below a critical value $U_{p/q}$, i.e., $U<U_{p/q}$.
On the other hand
 in the absence of magnetic field
 the staggered magnetization tends to appear
 even at small values of $U$.\cite{dagotto94}
The critical correlation strength $U_{p/q}$ is obtained by substituting $m=0$
 in Eq. (\ref{Uc}),
 and is shown for various values of $p/q$ in Table \ref{Uctable}.
For odd $q$ in $p/q$,
 the integral in Eq. (\ref{Uc}) is logarithmically divergent,
 and thus $U_{p/q}$ does not exist.
Although not numerically precise
 for the case of finite size calculations (solid lines),\cite{doh}
 with the even denominator values of $q$ in $p/q$
 a propensity of vanishing staggered magnetization
 is seen below $U_{p/q}$
 as shown in Fig.~\ref{undulatory}.
Thus the oscillatory behavior of the staggered magnetization
 is found to occur owing to its disappearance distinctively
at the even denominator values of $q$ in $p/q$.

\section{Conclusion}
We derived a generalized Harper's equation
 for the energy dispersion relation of
 interacting (antiferromagnetically correlated) electrons
 in an external magnetic field.
Unlike the original Harper's equation
 which deals only with noninteracting electron systems,
 the generalized Harper's equation
 derived in Eq. (\ref{genhar}) (with Eq. (\arabic{Hks}c))
 has a definite merit of studying the physical properties of
 correlated electron systems
 in the presence of the external magnetic field.
From this Harper's equation
 we derived an analytic formula
 for the density of states of the antiferromagnetically correlated electrons
 in the magnetic field.
For the limiting case of noninteracting electrons,
 the analytic equation for the density of states is found to be
 in good agreement with the numerical work of Hasegawa et al.\cite{hasegawa}
Further we presented the phase diagram of staggered magnetization
 in the plane of temperature $T$ vs doping rate $\delta$
 as a function of magnetic field
 (specifically, flux quanta per plaquette $p/q$)
 and correlation strength $U$.
From this study we demonstrated
 a possibility of reentrant behavior of staggered magnetization
 even in the presence of the applied magnetic field.
A more accurate account of electron correlations
 beyond the mean field approximations may not
 alter the qualitative nature of the reentrant behavior
 that we discovered in this study.
Although not reported here,
 we find from the exact diagonalization study of
 Hubbard model that
 the accurate account of correlations does not affect
 the qualitative finding here.
In the present study
 we neglected the Zeeman coupling.
At such large Coulomb repulsion energies as $U=8t$
 which we used in our calculations,
 we find that the Zeeman effect does not substantially alter
 the observed staggered magnetization.
For the case of half filling at zero temperature,
 we obtained a gap equation (\ref{Uc})
 for the determination of staggered magnetization
 for antiferromagnetically correlated electron systems
 at a given correlation strength $U$
 in the presence of magnetic field.
From this derivation we were able to determine
 a critical correlation strength $U_{p/q}$
 below which staggered magnetization disappears
 at even denominator values of $q$
 (but not at odd denominator values of $q$)
 of the magnetic flux quanta per plaquette, $p/q$.

\acknowledgments{
One (S.H.S.S) of the authors is grateful to the SRC program (1996) of
the Center for Molecular Science at KAIST.
He acknowledges the financial supports of
the Korean Ministry of Education BSRI (1997)
and POSTECH/BSRI.
He is also grateful to Professor Han-Yong Choi for earlier assistance.
}

redpajama_set_name: RedPajamaArXiv


, we choices the best series using best resolution simply for you, and this photos is usually one of graphics series in our greatest photographs gallery with regards to Free Resume Template Download for Word. Lets hope you might want it.
submitted by means of onlinesna at 2017-08-22 04:07:42. To determine most photographs inside Free Resume Template Download for Word pictures gallery please stick to this kind of website link.
Never forget to explore the next image album, which also includes the Free Resume Template Download For Word Beautiful Resume Sample Download In Word Valid Resume Template Microsoft Word image showed above. If you have any thoughts, questions or just want to say hello to other people, please do not hestitate to submit your opinion/ideas via the following comment form.


Emilia Clarke Says Her Star Wars Character Is "Awesome"
There has been a ton of news popping up recently from the Han Solo standalone film, and unfortunately it hasn't been all good due to the recent change in directors. Thankfully we now have at least one piece of encouraging news from one of the actors in the film.
"All I can say is that she's awesome. Like, legit, that's all I can actually get away with saying. There's a stormtrooper with a gun, and he's going to come walking in any second."
You can read the full interview over on Rolling Stone!
Emilia will star alongside Alden Ehrenreich, Donald Glover, Joonas Suotamo, Woody Harrelson, and many others. The untitled Han Solo film is set for release on May 25th, 2018!
I think a nice, in-character cast photo, to show off what they're going for, would be a good first-step toward quelling the growing doubt about this movie. I'm looking forward to it but I'm hoping to get genuinely excited at some point.


I have always been asked "Why the Food is my first love", and "Why I want to share it with the world". The true answers were revealed several years ago when I was asked to write about my culinary experiences by my good friend and author, Lorna Owens.
When the title of the book "Everyday Grace, Everyday Miracle: Living the life you were born to live" was released and I saw my story in the chapter called "Food for the Soul"; this globe trotting chef was humbled. It was then I knew I shared the vision of many Top Chefs in my industry.
The name of the book and the tile of the chapter are my story and the story behind what we do every day at The Miami Scene Food Group. Giving this, it is little wonder Miami Scene Food Group has been a driving force connected to only successful ventures. This trend setting group has the knowledge to elevate your project to the next level. Our service has that personal touch.
We look forward to hosting your next culinary experience.
© Copyright 2009 Stefano La Cava - www.ChefStefanoLaCava.com . All Rights are reserved.


text:
MongoDB's $150 Million Funding Round: It's about the Customer Experience
Today MongoDB announced that we raised $150 million from a variety of investors both new (Salesforce.com, T.Rowe Price, EMC and others) and old (Sequoia, Red Hat, NEA, Flybridge, etc.). It's a great day for MongoDB, both the company and the project. But mostly it's a great day for our customers and the MongoDB community in which they participate. Hip With The Hackers Over the last few years MongoDB has solidified its position as the industry's leading NoSQL database and the fastest-growing Big Data community . With this funding round, MongoDB is also the best funded Big Data technology. As enterprises invest in Big Data, they turn to the two dominant Big Data technologies, MongoDB and Hadoop , as Wikibon analysis has shown. Importantly, as can be seen in an analysis of LinkedIn profiles by 451 Research, very often enterprises discover that they already have MongoDB expertise within their organizations: Much of this success derives from MongoDB giving developers a better way to create applications . Rather than commoditizing a legacy relational database (RDBMS) market, similar to what other open-source RDBMSs have done, MongoDB significantly increases developer productivity by offering them a flexible data model. MongoDB is a significant part of what Cowen & Co. analyst Peter Goldmacher calls a "fundamental shift in the technology landscape away from legacy systems towards a new breed of better products at a lower cost for Data Management, Apps and in other areas." In other words, MongoDB is empowering the next generation of applications: post-transactional applications that rely on bigger data sets that move much faster than an RDBMS can handle. Developers have responded, voting with their apps, a considerable number of which are backed by MongoDB. A Means, Not An End Given the opportunity ahead of us, MongoDB would be irresponsible to raise less. While most of our funding comes from rapidly growing revenues, the MongoDB board of directors determined that it would be advantageous to the project and, hence, to our customers, to accelerate growth. After all, our relational database competitors have a 30-year headstart. As Max Schireson, MongoDB's CEO, articulated on his blog: We are in a market dominated by technologies with over 30 years of engineering in them. Their designs may not be as well suited to modern applications, but they are very mature, very feature rich, and have huge partner ecosystems and big companies that understand the needs of their enterprise customers behind them. They have way more tooling – and decades of refinement of operational tools. This is why we are raising $150 million. We know that it will take a large and sustained effort to build the maturity that many users expect in this market. Building out our management suite and enhancing the core product will be a ton of work. We have made great progress on security, management, stability, and scalability but we still have so much to do. For next-generation workloads in the cloud, MongoDB is already taking a lead, as Amazon Web Services data from Stackdriver seems to suggest: But MongoDB isn't intended to be a cloud-only database. It's a general purpose database, designed to be a great fit for the vast majority of worklads. We want to make it easy to run on a single node or at massive scale in the cloud or on premise. Whatever the customer needs. This funding will help. Helping Ops Fall In Love With MongoDB Some of that work will be done by MongoDB's exceptional community of developers and business partners. Among other things, the MongoDB community has contributed over 20 drivers, tripling the language compatibility of MongoDB and making it much more approachable for developers, whatever their preferred programming language. But some of it will necessarily be done by MongoDB, Inc. From Linux to JBoss to Drupal, much of the best tooling has had to be developed by a focused, highly incentivized company. MongoDB is no different. We believe we have built the world's best database for developers. Now we need to make sure it is also the world's best database for Operations professionals. So that means an improved and expanded management suite. We recently added Backup , but there are other areas that will help Operations professionals more easily manage MongoDB at the scale that we increasingly see enterprises run the database. Outside of tooling, we also recognize that we need to continue to make improvements to MongoDB's concurrency, further optimize performance and more. We don't by any stretch think we're done. The Path Forward But we're making excellent progress. In the last year since I joined MongoDB I've seen the company double its headcount and dramatically expand sales. This funding not only lets us make significant investments in improving MongoDB for both developers and Operations, but it also helps us to fund expansion geographically. We're already growing 300% or more in Europe year-over-year, and expect much of the same in Asia-Pacific. We need to help support our customers wherever they may be. Given the historic opportunity before MongoDB, it's time to step on the accelerator. Hard. -- If you're interested, please find more coverage of the funding at BusinessWeek , GigaOm , TechCrunch , VentureBeat , and ZDNet .