Metadata-Version: 2.4
Name: BranchManager
Version: 0.1.1
Summary: BranchManager: Answers the critical question — Has this microbial lineage already been isolated and characterised, or is it sufficiently novel and underrepresented to justify whole-genome sequencing (WGS) investment?
Author-email: Nicholas Dimonaco <nicholas@dimonaco.co.uk>
License:                     GNU GENERAL PUBLIC LICENSE
                               Version 3, 29 June 2007
        
         Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
         Everyone is permitted to copy and distribute verbatim copies
         of this license document, but changing it is not allowed.
        
                                    Preamble
        
          The GNU General Public License is a free, copyleft license for
        software and other kinds of works.
        
          The licenses for most software and other practical works are designed
        to take away your freedom to share and change the works.  By contrast,
        the GNU General Public License is intended to guarantee your freedom to
        share and change all versions of a program--to make sure it remains free
        software for all its users.  We, the Free Software Foundation, use the
        GNU General Public License for most of our software; it applies also to
        any other work released this way by its authors.  You can apply it to
        your programs, too.
        
          When we speak of free software, we are referring to freedom, not
        price.  Our General Public Licenses are designed to make sure that you
        have the freedom to distribute copies of free software (and charge for
        them if you wish), that you receive source code or can get it if you
        want it, that you can change the software or use pieces of it in new
        free programs, and that you know you can do these things.
        
          To protect your rights, we need to prevent others from denying you
        these rights or asking you to surrender the rights.  Therefore, you have
        certain responsibilities if you distribute copies of the software, or if
        you modify it: responsibilities to respect the freedom of others.
        
          For example, if you distribute copies of such a program, whether
        gratis or for a fee, you must pass on to the recipients the same
        freedoms that you received.  You must make sure that they, too, receive
        or can get the source code.  And you must show them these terms so they
        know their rights.
        
          Developers that use the GNU GPL protect your rights with two steps:
        (1) assert copyright on the software, and (2) offer you this License
        giving you legal permission to copy, distribute and/or modify it.
        
          For the developers' and authors' protection, the GPL clearly explains
        that there is no warranty for this free software.  For both users' and
        authors' sake, the GPL requires that modified versions be marked as
        changed, so that their problems will not be attributed erroneously to
        authors of previous versions.
        
          Some devices are designed to deny users access to install or run
        modified versions of the software inside them, although the manufacturer
        can do so.  This is fundamentally incompatible with the aim of
        protecting users' freedom to change the software.  The systematic
        pattern of such abuse occurs in the area of products for individuals to
        use, which is precisely where it is most unacceptable.  Therefore, we
        have designed this version of the GPL to prohibit the practice for those
        products.  If such problems arise substantially in other domains, we
        stand ready to extend this provision to those domains in future versions
        of the GPL, as needed to protect the freedom of users.
        
          Finally, every program is threatened constantly by software patents.
        States should not allow patents to restrict development and use of
        software on general-purpose computers, but in those that do, we wish to
        avoid the special danger that patents applied to a free program could
        make it effectively proprietary.  To prevent this, the GPL assures that
        patents cannot be used to render the program non-free.
        
          The precise terms and conditions for copying, distribution and
        modification follow.
        
                               TERMS AND CONDITIONS
        
          0. Definitions.
        
          "This License" refers to version 3 of the GNU General Public License.
        
          "Copyright" also means copyright-like laws that apply to other kinds of
        works, such as semiconductor masks.
        
          "The Program" refers to any copyrightable work licensed under this
        License.  Each licensee is addressed as "you".  "Licensees" and
        "recipients" may be individuals or organizations.
        
          To "modify" a work means to copy from or adapt all or part of the work
        in a fashion requiring copyright permission, other than the making of an
        exact copy.  The resulting work is called a "modified version" of the
        earlier work or a work "based on" the earlier work.
        
          A "covered work" means either the unmodified Program or a work based
        on the Program.
        
          To "propagate" a work means to do anything with it that, without
        permission, would make you directly or secondarily liable for
        infringement under applicable copyright law, except executing it on a
        computer or modifying a private copy.  Propagation includes copying,
        distribution (with or without modification), making available to the
        public, and in some countries other activities as well.
        
          To "convey" a work means any kind of propagation that enables other
        parties to make or receive copies.  Mere interaction with a user through
        a computer network, with no transfer of a copy, is not conveying.
        
          An interactive user interface displays "Appropriate Legal Notices"
        to the extent that it includes a convenient and prominently visible
        feature that (1) displays an appropriate copyright notice, and (2)
        tells the user that there is no warranty for the work (except to the
        extent that warranties are provided), that licensees may convey the
        work under this License, and how to view a copy of this License.  If
        the interface presents a list of user commands or options, such as a
        menu, a prominent item in the list meets this criterion.
        
          1. Source Code.
        
          The "source code" for a work means the preferred form of the work
        for making modifications to it.  "Object code" means any non-source
        form of a work.
        
          A "Standard Interface" means an interface that either is an official
        standard defined by a recognized standards body, or, in the case of
        interfaces specified for a particular programming language, one that
        is widely used among developers working in that language.
        
          The "System Libraries" of an executable work include anything, other
        than the work as a whole, that (a) is included in the normal form of
        packaging a Major Component, but which is not part of that Major
        Component, and (b) serves only to enable use of the work with that
        Major Component, or to implement a Standard Interface for which an
        implementation is available to the public in source code form.  A
        "Major Component", in this context, means a major essential component
        (kernel, window system, and so on) of the specific operating system
        (if any) on which the executable work runs, or a compiler used to
        produce the work, or an object code interpreter used to run it.
        
          The "Corresponding Source" for a work in object code form means all
        the source code needed to generate, install, and (for an executable
        work) run the object code and to modify the work, including scripts to
        control those activities.  However, it does not include the work's
        System Libraries, or general-purpose tools or generally available free
        programs which are used unmodified in performing those activities but
        which are not part of the work.  For example, Corresponding Source
        includes interface definition files associated with source files for
        the work, and the source code for shared libraries and dynamically
        linked subprograms that the work is specifically designed to require,
        such as by intimate data communication or control flow between those
        subprograms and other parts of the work.
        
          The Corresponding Source need not include anything that users
        can regenerate automatically from other parts of the Corresponding
        Source.
        
          The Corresponding Source for a work in source code form is that
        same work.
        
          2. Basic Permissions.
        
          All rights granted under this License are granted for the term of
        copyright on the Program, and are irrevocable provided the stated
        conditions are met.  This License explicitly affirms your unlimited
        permission to run the unmodified Program.  The output from running a
        covered work is covered by this License only if the output, given its
        content, constitutes a covered work.  This License acknowledges your
        rights of fair use or other equivalent, as provided by copyright law.
        
          You may make, run and propagate covered works that you do not
        convey, without conditions so long as your license otherwise remains
        in force.  You may convey covered works to others for the sole purpose
        of having them make modifications exclusively for you, or provide you
        with facilities for running those works, provided that you comply with
        the terms of this License in conveying all material for which you do
        not control copyright.  Those thus making or running the covered works
        for you must do so exclusively on your behalf, under your direction
        and control, on terms that prohibit them from making any copies of
        your copyrighted material outside their relationship with you.
        
          Conveying under any other circumstances is permitted solely under
        the conditions stated below.  Sublicensing is not allowed; section 10
        makes it unnecessary.
        
          3. Protecting Users' Legal Rights From Anti-Circumvention Law.
        
          No covered work shall be deemed part of an effective technological
        measure under any applicable law fulfilling obligations under article
        11 of the WIPO copyright treaty adopted on 20 December 1996, or
        similar laws prohibiting or restricting circumvention of such
        measures.
        
          When you convey a covered work, you waive any legal power to forbid
        circumvention of technological measures to the extent such circumvention
        is effected by exercising rights under this License with respect to
        the covered work, and you disclaim any intention to limit operation or
        modification of the work as a means of enforcing, against the work's
        users, your or third parties' legal rights to forbid circumvention of
        technological measures.
        
          4. Conveying Verbatim Copies.
        
          You may convey verbatim copies of the Program's source code as you
        receive it, in any medium, provided that you conspicuously and
        appropriately publish on each copy an appropriate copyright notice;
        keep intact all notices stating that this License and any
        non-permissive terms added in accord with section 7 apply to the code;
        keep intact all notices of the absence of any warranty; and give all
        recipients a copy of this License along with the Program.
        
          You may charge any price or no price for each copy that you convey,
        and you may offer support or warranty protection for a fee.
        
          5. Conveying Modified Source Versions.
        
          You may convey a work based on the Program, or the modifications to
        produce it from the Program, in the form of source code under the
        terms of section 4, provided that you also meet all of these conditions:
        
            a) The work must carry prominent notices stating that you modified
            it, and giving a relevant date.
        
            b) The work must carry prominent notices stating that it is
            released under this License and any conditions added under section
            7.  This requirement modifies the requirement in section 4 to
            "keep intact all notices".
        
            c) You must license the entire work, as a whole, under this
            License to anyone who comes into possession of a copy.  This
            License will therefore apply, along with any applicable section 7
            additional terms, to the whole of the work, and all its parts,
            regardless of how they are packaged.  This License gives no
            permission to license the work in any other way, but it does not
            invalidate such permission if you have separately received it.
        
            d) If the work has interactive user interfaces, each must display
            Appropriate Legal Notices; however, if the Program has interactive
            interfaces that do not display Appropriate Legal Notices, your
            work need not make them do so.
        
          A compilation of a covered work with other separate and independent
        works, which are not by their nature extensions of the covered work,
        and which are not combined with it such as to form a larger program,
        in or on a volume of a storage or distribution medium, is called an
        "aggregate" if the compilation and its resulting copyright are not
        used to limit the access or legal rights of the compilation's users
        beyond what the individual works permit.  Inclusion of a covered work
        in an aggregate does not cause this License to apply to the other
        parts of the aggregate.
        
          6. Conveying Non-Source Forms.
        
          You may convey a covered work in object code form under the terms
        of sections 4 and 5, provided that you also convey the
        machine-readable Corresponding Source under the terms of this License,
        in one of these ways:
        
            a) Convey the object code in, or embodied in, a physical product
            (including a physical distribution medium), accompanied by the
            Corresponding Source fixed on a durable physical medium
            customarily used for software interchange.
        
            b) Convey the object code in, or embodied in, a physical product
            (including a physical distribution medium), accompanied by a
            written offer, valid for at least three years and valid for as
            long as you offer spare parts or customer support for that product
            model, to give anyone who possesses the object code either (1) a
            copy of the Corresponding Source for all the software in the
            product that is covered by this License, on a durable physical
            medium customarily used for software interchange, for a price no
            more than your reasonable cost of physically performing this
            conveying of source, or (2) access to copy the
            Corresponding Source from a network server at no charge.
        
            c) Convey individual copies of the object code with a copy of the
            written offer to provide the Corresponding Source.  This
            alternative is allowed only occasionally and noncommercially, and
            only if you received the object code with such an offer, in accord
            with subsection 6b.
        
            d) Convey the object code by offering access from a designated
            place (gratis or for a charge), and offer equivalent access to the
            Corresponding Source in the same way through the same place at no
            further charge.  You need not require recipients to copy the
            Corresponding Source along with the object code.  If the place to
            copy the object code is a network server, the Corresponding Source
            may be on a different server (operated by you or a third party)
            that supports equivalent copying facilities, provided you maintain
            clear directions next to the object code saying where to find the
            Corresponding Source.  Regardless of what server hosts the
            Corresponding Source, you remain obligated to ensure that it is
            available for as long as needed to satisfy these requirements.
        
            e) Convey the object code using peer-to-peer transmission, provided
            you inform other peers where the object code and Corresponding
            Source of the work are being offered to the general public at no
            charge under subsection 6d.
        
          A separable portion of the object code, whose source code is excluded
        from the Corresponding Source as a System Library, need not be
        included in conveying the object code work.
        
          A "User Product" is either (1) a "consumer product", which means any
        tangible personal property which is normally used for personal, family,
        or household purposes, or (2) anything designed or sold for incorporation
        into a dwelling.  In determining whether a product is a consumer product,
        doubtful cases shall be resolved in favor of coverage.  For a particular
        product received by a particular user, "normally used" refers to a
        typical or common use of that class of product, regardless of the status
        of the particular user or of the way in which the particular user
        actually uses, or expects or is expected to use, the product.  A product
        is a consumer product regardless of whether the product has substantial
        commercial, industrial or non-consumer uses, unless such uses represent
        the only significant mode of use of the product.
        
          "Installation Information" for a User Product means any methods,
        procedures, authorization keys, or other information required to install
        and execute modified versions of a covered work in that User Product from
        a modified version of its Corresponding Source.  The information must
        suffice to ensure that the continued functioning of the modified object
        code is in no case prevented or interfered with solely because
        modification has been made.
        
          If you convey an object code work under this section in, or with, or
        specifically for use in, a User Product, and the conveying occurs as
        part of a transaction in which the right of possession and use of the
        User Product is transferred to the recipient in perpetuity or for a
        fixed term (regardless of how the transaction is characterized), the
        Corresponding Source conveyed under this section must be accompanied
        by the Installation Information.  But this requirement does not apply
        if neither you nor any third party retains the ability to install
        modified object code on the User Product (for example, the work has
        been installed in ROM).
        
          The requirement to provide Installation Information does not include a
        requirement to continue to provide support service, warranty, or updates
        for a work that has been modified or installed by the recipient, or for
        the User Product in which it has been modified or installed.  Access to a
        network may be denied when the modification itself materially and
        adversely affects the operation of the network or violates the rules and
        protocols for communication across the network.
        
          Corresponding Source conveyed, and Installation Information provided,
        in accord with this section must be in a format that is publicly
        documented (and with an implementation available to the public in
        source code form), and must require no special password or key for
        unpacking, reading or copying.
        
          7. Additional Terms.
        
          "Additional permissions" are terms that supplement the terms of this
        License by making exceptions from one or more of its conditions.
        Additional permissions that are applicable to the entire Program shall
        be treated as though they were included in this License, to the extent
        that they are valid under applicable law.  If additional permissions
        apply only to part of the Program, that part may be used separately
        under those permissions, but the entire Program remains governed by
        this License without regard to the additional permissions.
        
          When you convey a copy of a covered work, you may at your option
        remove any additional permissions from that copy, or from any part of
        it.  (Additional permissions may be written to require their own
        removal in certain cases when you modify the work.)  You may place
        additional permissions on material, added by you to a covered work,
        for which you have or can give appropriate copyright permission.
        
          Notwithstanding any other provision of this License, for material you
        add to a covered work, you may (if authorized by the copyright holders of
        that material) supplement the terms of this License with terms:
        
            a) Disclaiming warranty or limiting liability differently from the
            terms of sections 15 and 16 of this License; or
        
            b) Requiring preservation of specified reasonable legal notices or
            author attributions in that material or in the Appropriate Legal
            Notices displayed by works containing it; or
        
            c) Prohibiting misrepresentation of the origin of that material, or
            requiring that modified versions of such material be marked in
            reasonable ways as different from the original version; or
        
            d) Limiting the use for publicity purposes of names of licensors or
            authors of the material; or
        
            e) Declining to grant rights under trademark law for use of some
            trade names, trademarks, or service marks; or
        
            f) Requiring indemnification of licensors and authors of that
            material by anyone who conveys the material (or modified versions of
            it) with contractual assumptions of liability to the recipient, for
            any liability that these contractual assumptions directly impose on
            those licensors and authors.
        
          All other non-permissive additional terms are considered "further
        restrictions" within the meaning of section 10.  If the Program as you
        received it, or any part of it, contains a notice stating that it is
        governed by this License along with a term that is a further
        restriction, you may remove that term.  If a license document contains
        a further restriction but permits relicensing or conveying under this
        License, you may add to a covered work material governed by the terms
        of that license document, provided that the further restriction does
        not survive such relicensing or conveying.
        
          If you add terms to a covered work in accord with this section, you
        must place, in the relevant source files, a statement of the
        additional terms that apply to those files, or a notice indicating
        where to find the applicable terms.
        
          Additional terms, permissive or non-permissive, may be stated in the
        form of a separately written license, or stated as exceptions;
        the above requirements apply either way.
        
          8. Termination.
        
          You may not propagate or modify a covered work except as expressly
        provided under this License.  Any attempt otherwise to propagate or
        modify it is void, and will automatically terminate your rights under
        this License (including any patent licenses granted under the third
        paragraph of section 11).
        
          However, if you cease all violation of this License, then your
        license from a particular copyright holder is reinstated (a)
        provisionally, unless and until the copyright holder explicitly and
        finally terminates your license, and (b) permanently, if the copyright
        holder fails to notify you of the violation by some reasonable means
        prior to 60 days after the cessation.
        
          Moreover, your license from a particular copyright holder is
        reinstated permanently if the copyright holder notifies you of the
        violation by some reasonable means, this is the first time you have
        received notice of violation of this License (for any work) from that
        copyright holder, and you cure the violation prior to 30 days after
        your receipt of the notice.
        
          Termination of your rights under this section does not terminate the
        licenses of parties who have received copies or rights from you under
        this License.  If your rights have been terminated and not permanently
        reinstated, you do not qualify to receive new licenses for the same
        material under section 10.
        
          9. Acceptance Not Required for Having Copies.
        
          You are not required to accept this License in order to receive or
        run a copy of the Program.  Ancillary propagation of a covered work
        occurring solely as a consequence of using peer-to-peer transmission
        to receive a copy likewise does not require acceptance.  However,
        nothing other than this License grants you permission to propagate or
        modify any covered work.  These actions infringe copyright if you do
        not accept this License.  Therefore, by modifying or propagating a
        covered work, you indicate your acceptance of this License to do so.
        
          10. Automatic Licensing of Downstream Recipients.
        
          Each time you convey a covered work, the recipient automatically
        receives a license from the original licensors, to run, modify and
        propagate that work, subject to this License.  You are not responsible
        for enforcing compliance by third parties with this License.
        
          An "entity transaction" is a transaction transferring control of an
        organization, or substantially all assets of one, or subdividing an
        organization, or merging organizations.  If propagation of a covered
        work results from an entity transaction, each party to that
        transaction who receives a copy of the work also receives whatever
        licenses to the work the party's predecessor in interest had or could
        give under the previous paragraph, plus a right to possession of the
        Corresponding Source of the work from the predecessor in interest, if
        the predecessor has it or can get it with reasonable efforts.
        
          You may not impose any further restrictions on the exercise of the
        rights granted or affirmed under this License.  For example, you may
        not impose a license fee, royalty, or other charge for exercise of
        rights granted under this License, and you may not initiate litigation
        (including a cross-claim or counterclaim in a lawsuit) alleging that
        any patent claim is infringed by making, using, selling, offering for
        sale, or importing the Program or any portion of it.
        
          11. Patents.
        
          A "contributor" is a copyright holder who authorizes use under this
        License of the Program or a work on which the Program is based.  The
        work thus licensed is called the contributor's "contributor version".
        
          A contributor's "essential patent claims" are all patent claims
        owned or controlled by the contributor, whether already acquired or
        hereafter acquired, that would be infringed by some manner, permitted
        by this License, of making, using, or selling its contributor version,
        but do not include claims that would be infringed only as a
        consequence of further modification of the contributor version.  For
        purposes of this definition, "control" includes the right to grant
        patent sublicenses in a manner consistent with the requirements of
        this License.
        
          Each contributor grants you a non-exclusive, worldwide, royalty-free
        patent license under the contributor's essential patent claims, to
        make, use, sell, offer for sale, import and otherwise run, modify and
        propagate the contents of its contributor version.
        
          In the following three paragraphs, a "patent license" is any express
        agreement or commitment, however denominated, not to enforce a patent
        (such as an express permission to practice a patent or covenant not to
        sue for patent infringement).  To "grant" such a patent license to a
        party means to make such an agreement or commitment not to enforce a
        patent against the party.
        
          If you convey a covered work, knowingly relying on a patent license,
        and the Corresponding Source of the work is not available for anyone
        to copy, free of charge and under the terms of this License, through a
        publicly available network server or other readily accessible means,
        then you must either (1) cause the Corresponding Source to be so
        available, or (2) arrange to deprive yourself of the benefit of the
        patent license for this particular work, or (3) arrange, in a manner
        consistent with the requirements of this License, to extend the patent
        license to downstream recipients.  "Knowingly relying" means you have
        actual knowledge that, but for the patent license, your conveying the
        covered work in a country, or your recipient's use of the covered work
        in a country, would infringe one or more identifiable patents in that
        country that you have reason to believe are valid.
        
          If, pursuant to or in connection with a single transaction or
        arrangement, you convey, or propagate by procuring conveyance of, a
        covered work, and grant a patent license to some of the parties
        receiving the covered work authorizing them to use, propagate, modify
        or convey a specific copy of the covered work, then the patent license
        you grant is automatically extended to all recipients of the covered
        work and works based on it.
        
          A patent license is "discriminatory" if it does not include within
        the scope of its coverage, prohibits the exercise of, or is
        conditioned on the non-exercise of one or more of the rights that are
        specifically granted under this License.  You may not convey a covered
        work if you are a party to an arrangement with a third party that is
        in the business of distributing software, under which you make payment
        to the third party based on the extent of your activity of conveying
        the work, and under which the third party grants, to any of the
        parties who would receive the covered work from you, a discriminatory
        patent license (a) in connection with copies of the covered work
        conveyed by you (or copies made from those copies), or (b) primarily
        for and in connection with specific products or compilations that
        contain the covered work, unless you entered into that arrangement,
        or that patent license was granted, prior to 28 March 2007.
        
          Nothing in this License shall be construed as excluding or limiting
        any implied license or other defenses to infringement that may
        otherwise be available to you under applicable patent law.
        
          12. No Surrender of Others' Freedom.
        
          If conditions are imposed on you (whether by court order, agreement or
        otherwise) that contradict the conditions of this License, they do not
        excuse you from the conditions of this License.  If you cannot convey a
        covered work so as to satisfy simultaneously your obligations under this
        License and any other pertinent obligations, then as a consequence you may
        not convey it at all.  For example, if you agree to terms that obligate you
        to collect a royalty for further conveying from those to whom you convey
        the Program, the only way you could satisfy both those terms and this
        License would be to refrain entirely from conveying the Program.
        
          13. Use with the GNU Affero General Public License.
        
          Notwithstanding any other provision of this License, you have
        permission to link or combine any covered work with a work licensed
        under version 3 of the GNU Affero General Public License into a single
        combined work, and to convey the resulting work.  The terms of this
        License will continue to apply to the part which is the covered work,
        but the special requirements of the GNU Affero General Public License,
        section 13, concerning interaction through a network will apply to the
        combination as such.
        
          14. Revised Versions of this License.
        
          The Free Software Foundation may publish revised and/or new versions of
        the GNU General Public License from time to time.  Such new versions will
        be similar in spirit to the present version, but may differ in detail to
        address new problems or concerns.
        
          Each version is given a distinguishing version number.  If the
        Program specifies that a certain numbered version of the GNU General
        Public License "or any later version" applies to it, you have the
        option of following the terms and conditions either of that numbered
        version or of any later version published by the Free Software
        Foundation.  If the Program does not specify a version number of the
        GNU General Public License, you may choose any version ever published
        by the Free Software Foundation.
        
          If the Program specifies that a proxy can decide which future
        versions of the GNU General Public License can be used, that proxy's
        public statement of acceptance of a version permanently authorizes you
        to choose that version for the Program.
        
          Later license versions may give you additional or different
        permissions.  However, no additional obligations are imposed on any
        author or copyright holder as a result of your choosing to follow a
        later version.
        
          15. Disclaimer of Warranty.
        
          THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
        APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
        HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
        OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
        THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
        IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
        ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
        
          16. Limitation of Liability.
        
          IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
        WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
        THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
        GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
        USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
        DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
        PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
        EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
        SUCH DAMAGES.
        
          17. Interpretation of Sections 15 and 16.
        
          If the disclaimer of warranty and limitation of liability provided
        above cannot be given local legal effect according to their terms,
        reviewing courts shall apply local law that most closely approximates
        an absolute waiver of all civil liability in connection with the
        Program, unless a warranty or assumption of liability accompanies a
        copy of the Program in return for a fee.
        
                             END OF TERMS AND CONDITIONS
        
                    How to Apply These Terms to Your New Programs
        
          If you develop a new program, and you want it to be of the greatest
        possible use to the public, the best way to achieve this is to make it
        free software which everyone can redistribute and change under these terms.
        
          To do so, attach the following notices to the program.  It is safest
        to attach them to the start of each source file to most effectively
        state the exclusion of warranty; and each file should have at least
        the "copyright" line and a pointer to where the full notice is found.
        
            <one line to give the program's name and a brief idea of what it does.>
            Copyright (C) <year>  <name of author>
        
            This program is free software: you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation, either version 3 of the License, or
            (at your option) any later version.
        
            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.
        
            You should have received a copy of the GNU General Public License
            along with this program.  If not, see <https://www.gnu.org/licenses/>.
        
        Also add information on how to contact you by electronic and paper mail.
        
          If the program does terminal interaction, make it output a short
        notice like this when it starts in an interactive mode:
        
            <program>  Copyright (C) <year>  <name of author>
            This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
            This is free software, and you are welcome to redistribute it
            under certain conditions; type `show c' for details.
        
        The hypothetical commands `show w' and `show c' should show the appropriate
        parts of the General Public License.  Of course, your program's commands
        might be different; for a GUI interface, you would use an "about box".
        
          You should also get your employer (if you work as a programmer) or school,
        if any, to sign a "copyright disclaimer" for the program, if necessary.
        For more information on this, and how to apply and follow the GNU GPL, see
        <https://www.gnu.org/licenses/>.
        
          The GNU General Public License does not permit incorporating your program
        into proprietary programs.  If your program is a subroutine library, you
        may consider it more useful to permit linking proprietary applications with
        the library.  If this is what you want to do, use the GNU Lesser General
        Public License instead of this License.  But first, please read
        <https://www.gnu.org/licenses/why-not-lgpl.html>.
        
Project-URL: Homepage, https://github.com/NickJD/BranchManager
Project-URL: Bug Tracker, https://github.com/NickJD/BranchManager/issues
Keywords: Isolate Collection,Marker Gene,Whole Genome Sequencing,Microbial Lineage,Novelty Assessment
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib>=3.10.8
Dynamic: license-file

**SYSTEM OVERVIEW & GUIDE**

**BranchManager**

Marker-Gene Quality Control, Novelty Scoring, & Genome-Candidate Prioritisation Toolkit

**Core Mission:** _Answers the critical question - "Has this microbial lineage already been isolated and characterised, or is it sufficiently novel and underrepresented to justify whole-genome sequencing (WGS) investment?"_

**1\. Executive Summary**

**BranchManager** is an end-to-end biological decision-support platform built for microbiology laboratories, research consortia, and biobanks managing large isolate collections. When processing thousands of physical isolates, determining which candidates warrant high-cost downstream sequencing is a major bottleneck.

BranchManager streamlines this process by evaluating marker-gene sequences (such as 16S rRNA), performing strict quality control on raw instrument chromatograms, classifying sequences across multiple global taxonomy databases, measuring multi-layered biological novelty, and proposing optimal primary and backup candidate sets for whole-genome sequencing.

| **🔬 Automated Quality Control**<br><br>Evaluates raw Sanger/AB1 chromatogram trace files, trims low-quality ends, detects mixed peaks, quality-weights overlapping reads, and isolates failed sequences for manual review. | **🌐 Multi-Lens Novelty**<br><br>Measures sequence divergence independently against internal physical lab baselines (The Hungate Collection), rolling multi-partner candidate collections, and global public references (GTDB, SILVA). | **🎯 Balanced Selection**<br><br>Maintains configurable pangenome targets per species, picking primary target candidates to fill genomic gaps while reserving backup strains for extraction failure resilience. |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

**2\. Core Operational Ethos & Principles**

**• Absence of a Hit ≠ Novelty:** A sequence lacking close reference hits is not automatically novel. It may represent poor trace quality, chimeric sequences, contamination, or incomplete coverage. BranchManager enforces strict QC filtering before novelty scoring.

**• Facts vs. Recommendations are Kept Distinct:** Factual states (e.g., physical DNA availability, confirmed genome presence, QC status) are maintained independently from recommendation states (e.g., Primary vs. Backup nomination). Recommendation flags never modify factual records automatically.

**• Fail-Closed Safety Principles:** Selection-critical processes fail closed. An incomplete tree build, unverified quality score, or broken novelty calculation will halt report publication rather than generating superficially valid recommendations.

**• Novelty is Relative to YOUR Project:** Novelty metrics specifically measure how unique an isolate is compared to what your project or lab has already characterised, helping to prevent redundant sequencing of strains already in your freezer.

**3\. The Workflow Stages ("Office Vocabulary")**

BranchManager uses an "office workflow" vocabulary to guide users through the multi-step candidate selection lifecycle from initial delivery to annual reporting:

| **Workflow Stage**      | **Scientific Purpose**                                                                                            | **Key Outputs & Deliverables**                                                           |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| **Mailroom**            | Inventories physical AB1 chromatogram deliveries, reconciles read IDs, and verifies primer metadata.              | Batch map (ab1_map.tsv), read inventory, missing/duplicate read reports.                 |
| **Interview**           | Standalone chromatogram QC and resequencing triage without project database modifications.                        | QC assembly report, resequencing recommendations, failed trace manifests.                |
| **Onboarding**          | Validates metadata ledgers, confirms isolate ownership, and enforces unique project ID mapping.                   | Normalised input datasets, partner ledger validation logs.                               |
| **Paper Trail & Merge** | Converts raw AB1/FASTQ traces, trims low-quality ends, masks low-confidence bases, and merges multi-primer reads. | Assembled FASTA, per-base error profiles, trace visual reports, manual review templates. |
| **Filing Cabinet**      | Registers cultured baseline datasets (e.g., Hungate) and constructs initial reference backbone trees.             | Baseline taxonomy tables, initial tree structures, baseline identity maps.               |
| **Performance Review**  | Classifies marker sequences, screens chimeras, scores multi-lens novelty, and updates phylogenetic trees.         | Sequence audit table, novelty summary, iTOL metadata strips, local clade figures.        |
| **Hiring Panel**        | Proposes group-level primary and backup isolate candidates based on current pangenome targets.                    | Selection summaries, primary/backup diversity plans, dashboard interface.                |
| **Quarterly Review**    | Reconsiders full collections across partner batches to select budgeted genome sequencing tranches.                | Tranche nomination lists, marginal distance audits, updated clade visual maps.           |
| **Status & Records**    | Imports factual lab progress (e.g., extraction success, completed WGS assemblies, ANI results).                   | Updated genome collections, factual isolate status logs, ANI quality gates.              |
| **Annual Report**       | Generates cumulative, audit-ready marker-to-genome close-out reports for institutional stakeholders.              | Executive HTML dashboard, complete historical audit trail, ledger close-outs.            |

**4\. Key System Tools & Operational Modules**

**Unified Golden-Path Runner (assistant)**

The primary standard execution route. It orchestrates Onboarding, Paper Trail quality control, Performance Review novelty calculations, and Hiring Panel candidate selection in an integrated sequence with zero manual intermediate handling.

**Chromatogram Quality Control Engine (mailroom, interview, paper-trail)**

Processes raw Sanger sequencing files. Performs Phred quality score evaluation, end-trimming, internal base masking, dye-channel peak analysis for mixed/heterozygous positions, and orientation-aware multi-read consensus assembly. Sequences failing QC are isolated in a dedicated triage folder with detailed diagnostic reason codes.

**Baseline & Reference Classifier (filing-cabinet)**

Loads physical baseline datasets (such as cultured strain biobanks) to anchor phylogenetic trees and establish the initial novelty threshold. Supports multi-database taxonomic reporting (GTDB, SILVA, GG2, NCBI).

**Novelty Scoring & Selection Engine (performance-review, quarterly-review)**

Evaluates incoming candidate datasets against the accumulating project database. Calculates neighbourhood crowding metrics, identifies baseline-redundant strains (≥99.8% identity across ≥95% alignment), and applies farthest-first phylogenetic branch distance calculations to pick optimal isolate subsets.

**Focused Taxonomy Slicing & Tree Styling (org-chart, label-maker)**

Allows researchers to instantly extract specific taxons (e.g., domain Archaea or family Lachnospiraceae) from existing alignments to generate high-resolution focused phylogenetic trees and customise interactive iTOL visual metadata strips without recomputing alignments.

**5\. Candidate Selection & Decision Categories**

BranchManager replaces subjective manual picking with a transparent, evidence-based selection model. Decisions are presented clearly for expert-human review:

| **Decision Category**            | **Status Type**        | **Scientific Rationale & Use Case**                                                                                                       |
| -------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **PRIORITISE - SET PRIMARY**     | **Primary Nomination** | High-value candidate filling an unrepresented species gap or missing pangenome slot. Highest priority for WGS.                            |
| **RESERVE - SET BACKUP**         | **Backup Candidate**   | Phylogenetically diverse strain retained as a secondary option in case the primary candidate fails DNA extraction or library preparation. |
| **EXCLUDE - BASELINE REDUNDANT** | **Excluded Strain**    | Strain sharing ≥99.8% 16S identity over ≥95% coverage with an already-cultured baseline strain. Omitted to prevent redundant sequencing.  |
| **REVIEW - PANGENOME BOUNDARY**  | **Manual Review**      | Sequence falls near species identity boundaries; requires manual review to confirm if it represents a distinct novel lineage.             |
| **LOWER PRIORITY - TARGET MET**  | **Lower Priority**     | The maximum target number of genomes for this exact GTDB species has already been satisfied by existing baseline or pending genomes.      |

**6\. Core Benefits & Strategic Value**

**• Sequencing Budget Optimisation:** Prevents spending WGS resources on isolates that duplicate strains already characterised in internal or public biobanks.

**• Multi-Partner Harmonisation:** Provides a single source of truth database across multiple contributing laboratories, ensuring consistent ID mapping and metadata tracking.

**• Maximum Diversity Capture:** Utilises branch-length algorithms to pick candidates that maximise phylogenetic spread across target clades.

**• Full Auditability & Reproducibility:** Every candidate recommendation is linked to raw chromatograms, specific quality metrics, component novelty scores, and paginated visual trace reports.

**• Scalable Tranche Management:** Supports phased sequencing rounds (e.g., quarterly budgets), automatically updating recommendations as newly sequenced genomes become available.


## Quick start

### Collection profiles

Use a JSON project profile to keep collection-specific names, reference databases, baseline datasets, anchor FASTA, domain, and selection policy together. A profile supplies defaults; an explicit command-line option always takes precedence. Copy [`configs/project.template.json`](configs/project.template.json) and edit it for a collection. Environment substitutions use `${NAME}` or `${NAME:-fallback}`, allowing local paths to stay out of shared configuration files. Relative data paths are resolved from the profile's directory.

The checked-in [`configs/rumen_gateway.json`](configs/rumen_gateway.json) records the current Rumen Gateway assumptions: GTDB r232 primary taxonomy, Greengenes2 2024.09 cross-check, Hungate priority baseline, Rumen Gateway MWL, nine-genome target, current redundancy/extension thresholds, and the bundled Rumen Gateway-era anchor set. Its historical external paths can be overridden with the `RGW_*` environment variables shown in that file, or directly on the command line. For example:

```bash
branchmanager assistant --config configs/rumen_gateway.json \
  --sample-map batch_map.tsv --db project.sqlite --dataset Collection_01 \
  --partner-id LAB_A -o runs/Collection_01
```

The profile's `project` object is collection metadata and is copied into run manifests; `data` documents relevant files; `defaults` maps command names to CLI argument names. Each run manifest records the profile file checksum. Additional columns in the partner ledger are retained per isolate in the database's `sequencing_metadata.project_metadata_json` field, while BranchManager interprets its standard ID, partner, selection, and genome-availability columns. The Rumen Gateway anchor set is a profile default and should be replaced with vetted, domain-appropriate anchors for other collections. See [collection profiles and scope](docs/collection-profiles-and-validation.md) before interpreting results from a new marker/domain.

Profiles can declare multiple baselines under `baselines`, each with a unique `dataset`, `fasta`, `tier` (`priority` or `secondary`), and optional `taxonomy_assignments` or `classify`. A single Filing Cabinet invocation loads each baseline into its own dataset and tier, then builds one combined backbone from the available marker sequences:

```bash
branchmanager filing-cabinet --config configs/rumen_gateway.json \
  --db project.sqlite --build-tree -o filing_cabinet
```

The profile's `project.selection_budget` supplies the default number of primary genomes nominated in a Quarterly Review; override it with `--genome-budget`. Backups are controlled separately. In a validation table, precision@k is the fraction of the k selected candidates that meet the prespecified success outcome, while recall@k is the fraction of all successful candidates recovered among those k. These metrics should use the same k as the real sequencing budget.

For a complete partner submission, use the guarded golden path:

```bash
branchmanager assistant \
  --sample-map ab1_mapping.tsv \
  --partner-metadata partner_metadata.tsv \
  --db project.sqlite --dataset QUB_01 \
  --ref gtdb_ssu_reps.fna.gz --ref-name GTDB \
  --chimera-ref silva_gold_ssu.fasta.gz \
  --baseline-fasta hungate.fasta --baseline-dataset Hungate \
  --mwl MWL.csv --threads 10 \
  -o runs/01_QUB_01
```

`assistant` runs IT Desk checks, Onboarding, Paper Trail/Merge Meeting, Performance Review, and Hiring Panel in numbered directories. Each stage remains independently runnable:

```bash
# 1. Establish the cultured baseline Filing Cabinet and build a reference tree
branchmanager filing-cabinet \
  --fasta hungate.fasta \
  --db project.db \
  --dataset Hungate \
  --ref gtdb_r232_bac_arch_ssu_reps.fna \
  --classify --build-tree \
  -o filing_cabinet_out \
  --threads 10

# 2. Process new sequences — scores novelty against the baseline
branchmanager performance-review \
  --input new_sequences.fasta \
  --db project.db \
  --dataset Batch1 \
  --ref gtdb_r232_bac_arch_ssu_reps.fna \
  --previous-review filing_cabinet_out \
  -o batch1_out \
  --threads 10

# 3. Zoom into a specific taxon
branchmanager org-chart \
  --db project.db \
  --taxon archaea \
  --from-dir filing_cabinet_out \
  -o archaea_out

# 4. Regenerate iTOL files with new grouping options
branchmanager label-maker \
  --db project.db \
  --out filing_cabinet_out \
  --group-phyla archaea \
  --group-phyla "Bacillota,Bacillota_I,Bacillota_A"
```

---

## Core concepts

### Novelty is relative to YOUR submitted sequences

All novelty and neighbourhood-density calculations are made against the sequences submitted to BranchManager (the Filing Cabinet baseline plus all prior Performance Review datasets stored in the DB). They are **not** made against the full external reference (GTDB/SILVA).

This is intentional: BranchManager helps you judge whether a new sequence is worth investigating relative to what your lab or project has already characterised — not relative to all known biology.

Each successive Performance Review extends the reference pool, so novelty scores become increasingly precise as your project grows.

### Three-layer tree architecture

The phylogenetic tree is built from three independent layers:

| Layer | Source | Shown in iTOL? |
|---|---|---|
| 1 — Anchors | 26 NCBI RefSeq anchor sequences (bundled) | **No** — invisible topology scaffolding |
| 2 — Filing Cabinet | Your cultured baseline dataset (e.g. Hungate) | Yes |
| 3 — Performance Review | Each new partner marker batch | Yes |

Anchor sequences constrain phylum-level topology during MAFFT + FastTree inference, then are pruned from the stored newick. They are never shown in outputs, iTOL files, or novelty scoring.

---

## Subcommands

### `branchmanager filing-cabinet` 

Load a baseline FASTA dataset, classify against a reference, and build the backbone tree. This is always the first step.

```bash
branchmanager filing-cabinet \
  --fasta baseline.fasta \
  --db project.db \
  --dataset Hungate \
  --ref gtdb_r232_bac_arch_ssu_reps.fna \
  --classify --build-tree \
  -o filing_cabinet_out \
  --threads 10 \
  --collapse
```

| Parameter | Required | Default | Description |
|---|---|---|---|
| `--fasta` | ✓ | — | Input FASTA file containing the baseline sequences |
| `--db` | ✓ | — | Path to the BranchManager SQLite database (created if absent) |
| `-o / --out` | | `.` | Output directory for tree, iTOL files, and reports |
| `--dataset` | ✓ | — | Label stored in the DB (e.g. `Hungate`) |
| `--ref` | | — | Reference FASTA (GTDB/SILVA reps) for classification and tree orientation |
| `--classify` | | off | Classify sequences against `--ref` and store taxonomy |
| `--build-tree` | | off | Build the MAFFT + FastTree backbone tree |
| `--taxa` | | — | TSV mapping reference IDs to lineages (optional when `--ref` headers contain GTDB lineages) |
| `--taxa-assignments` | | — | Pre-computed taxonomy for the INPUT sequences (TSV or embedded-lineage FASTA) |
| `--shorten-ids / --no-shorten-ids` | | `--no-shorten-ids` | Preserve input headers exactly by default; use `--shorten-ids` only when compact generated IDs are desired |
| `--collapse` | | off | Collapse near-identical same-taxonomy sequences into one representative for the tree |
| `--collapse-threshold` | | `99.8` | Identity threshold (%) for collapsing |
| `--sequence-domain` | | `bacteria` | Domain/profile to process: `bacteria`, `archaea`, `fungi`, or `mixed`/`all`/`none` to disable filtering. Use matching references, previous reviews, and anchors for non-bacterial runs |
| `--anchors` | | bundled | Custom anchor FASTA for tree topology scaffolding |
| `--threads` | | `4` | CPU threads for MAFFT and VSEARCH |
| `--colours` | | — | CSV mapping sequence IDs to custom hex colours for iTOL (columns: `id`, `colour`) |
| `--group-phyla SPEC` | | — | Group phyla into a single colour in iTOL (repeatable; see *Phylum grouping*) |
| `--functional` | | — | TSV file mapping sequence IDs to functional attributes (first column = ID; subsequent columns = attributes). Generates one iTOL file per column (DATASET_BINARY / DATASET_SIMPLEBAR / DATASET_COLORSTRIP). |

---

### `branchmanager mailroom`

Prepare the immutable per-batch AB1 map before Onboarding. Mailroom scans every physical chromatogram, extracts ABIF sample/run/instrument and base-call evidence, reconciles supplier sequencing IDs, and reports missing, duplicated, ambiguous, or unmapped reads.

```bash
branchmanager mailroom \
  --read-dir UoG/All_AB1 \
  --metadata UoG/supplier_metadata.csv \
  --dataset UoG_01 \
  --forward-primer 63F \
  --reverse-primer 1492R \
  -o UoG/UoG_01
```

Only use `--forward-primer` and `--reverse-primer` after the oligonucleotides have been confirmed from the partner protocol or sequencing submission. Supplier metadata may instead contain a `primer` column. Mailroom uses embedded ABIF primer names when present, but never treats sequence-motif similarity as proof of the exact primer.

Preferred supplier-metadata columns:

```tsv
sequencing_id	isolate_number	read	primer	processing_mode
KKX994	SW_0016	Forward	63F	assemble
KKY011	SW_0016	Reverse	1492R	assemble
```

`primer` and `processing_mode` are optional. With `--processing-mode auto`, paired/multi-read isolates use `assemble` and single-read isolates use `best_read`.

| Output | Purpose |
|---|---|
| `ab1_map.tsv` | Validated one-row-per-read input for Onboarding |
| `ab1_inventory.tsv` | Physical file and extracted ABIF metadata inventory |
| `mailroom_report.tsv` | Missing, duplicate, ambiguous, unreadable, unmapped, and unresolved-primer findings |
| `mailroom_summary.json` | Machine-readable counts and `PASS`, `REVIEW_REQUIRED`, or `FAIL` status |
| `run_manifest.json` | Checksums, inputs, outputs, and stage status |

Mailroom returns `REVIEW_REQUIRED` when files reconcile but primer names remain unresolved, and `FAIL` for structural/file errors. Correct the supplier metadata or confirm primers before Onboarding.

For PacBio 16S, retain the same Mailroom entry point but select the technology explicitly. PacBio Mailroom validates one segmented HiFi FASTQ per isolate, reconciles it with the supplied `sequenceid`/`sequence_id` and `read_file`/`fastq_file` columns, writes `pacbio_map.tsv`, and automatically runs clustering and representative selection under `pacbio_16s_import/`. Sanger remains the default.

```bash
branchmanager mailroom \
  --technology pacbio \
  --read-dir UKNZ_01/All_Pacbio \
  --metadata UKNZ_01/UKNZ_01_pacbio_metadata.csv \
  --dataset UKNZ_01 \
  -o UKNZ_01/mailroom
```

---

### `branchmanager interview`

Run AB1 conversion and QC without Onboarding, taxonomy, tree building, candidate selection, or any project-database access. Interview consumes the complete Mailroom output directory and uses the same versioned QC policy as `assistant`.

```bash
branchmanager interview \
  --mailroom UoG/UoG_01 \
  --screen-ref gtdb_r232_bac_arch_ssu_reps.fna.gz \
  --threads 10 \
  -o UoG/UoG_01_interview
```

`--screen-ref` is optional and only checks whether separate primer reads from the same isolate have discordant taxonomic hits. A disagreement produces `PASS_WITH_WARNINGS / MANUAL_REVIEW` unless another QC criterion fails. The common comparison rank and each `read_id=taxon` assignment are written to the concordance, assembly, recommendation, and review tables. Without it, all chromatogram, trimming, assembly, quality, ambiguity, mixed-peak, and resequencing outputs are still produced.

Interview accepts either the Mailroom directory or its `ab1_map.tsv`. It requires the accompanying `mailroom_summary.json`, rejects a Mailroom `FAIL`, and stops on `REVIEW_REQUIRED` unless the batch has been reviewed and `--allow-mailroom-review` is supplied explicitly.

The principal hand-off files are `assembled.fasta`, `assembly_report.tsv`, `marker_review_template.tsv`, and `resequence_recommendations.tsv`. Once any manual-review decisions are completed, these can enter the full workflow without repeating chromatogram processing:

```bash
branchmanager assistant \
  --fasta UoG/UoG_01_interview/assembled.fasta \
  --marker-qc UoG/UoG_01_interview/assembly_report.tsv \
  --marker-review UoG/UoG_01_interview/marker_review_template.tsv \
  --partner-metadata Sequence_Metadata.csv \
  --db project.sqlite --dataset UoG_01 --ref gtdb_ssu_reps.fna.gz \
  -o runs/UoG_01
```

Do not supply the blank review template to Assistant. Add decisions only for the listed `PASS_WITH_WARNINGS` markers first; omit `--marker-review` when the template contains no rows.

---

### `branchmanager onboarding`

Every partner dataset is onboarded from exactly one marker source. AB1 submissions use a sample map; FASTA-only submissions use the FASTA directly. Both paths validate sequence IDs against the same cumulative project metadata ledger.

```bash
# AB1 or multiple primer reads
branchmanager onboarding \
  --sample-map UoG/UoG_01/ab1_map.tsv \
  --read-dir UoG_01_AB1/ \
  --partner-metadata project_partner_metadata.tsv \
  --partner-id UoG --dataset UoG_01 \
  -o UoG_01/01_onboarding

# Partner-supplied marker FASTA; .gz is accepted
branchmanager onboarding \
  --fasta QUB_01_16S.fasta.gz \
  --partner-metadata project_partner_metadata.tsv \
  --partner-id QUB --dataset QUB_01 \
  -o QUB_01/01_onboarding
```

FASTA Onboarding writes `normalised_input.fasta`. It does not invent chromatogram quality evidence. Supply a reviewed `--marker-qc` table to Performance Review where one exists, or use `--accept-unverified-marker-qc` as an explicit audited acceptance; unverified marker evidence remains visible in the reports.

### PacBio 16S partner submissions

Use PacBio 16S only after SMRT Link has segmented/de-concatenated and demultiplexed the library molecules. One FASTQ is supplied per cultured isolate, containing many observations of the approximately 1.5 kb full-length 16S amplicon. BranchManager filters reads by length and mean quality, dereplicates them, clusters the unique sequences with vsearch at 99.5% identity, and selects the highest-abundance observed sequence from the dominant cluster. An isolate passes only when it has at least 20 passing reads and the dominant cluster contains at least 80% of them; adjust these defaults only with documented validation. The current default library provenance is `Kinnex 16S rRNA`; it is recorded in the marker QC reason field alongside the SMRT Link segmentation workflow.

```tsv
sequence_id	fastq_file
Iso001	fastq/Iso001.fastq.gz
Iso002	fastq/Iso002.fastq.gz
```

```bash
branchmanager pacbio-16s-import --pacbio-map QUB_PACBIO_01/pacbio_map.tsv -o QUB_PACBIO_01/00_pacbio_16s

# Or run it as the partner-sequenced input to the full workflow:
branchmanager assistant --pacbio-map QUB_PACBIO_01/pacbio_map.tsv \
  --partner-metadata project_partner_metadata.tsv --partner-id QUB --dataset QUB_PACBIO_01 \
  --db project.db --ref gtdb_16s.fasta -o QUB_PACBIO_01/run
```

PacBio 16S Import writes `pacbio_16s_representatives.fasta`, `marker_qc.tsv`, `read_qc.tsv`, and `pacbio_16s_qc.tsv`. Failed or mixed isolates are excluded from the marker FASTA and remain visible in the QC report; `read_qc.tsv` retains the source FASTQ link in the downstream provenance, while raw FASTQs and the per-isolate clustering work files remain available for audit. The PacBio QC sidecar is consumed automatically by `assistant`, so it is not accepted as unverified partner FASTA.

Partner acronyms and submission labels are separate. For example, `UoG_01` and `UoG_02` are distinct `--dataset` values, while both sets of ledger rows use `partner_id=UoG`. Sequence IDs must be unique and stable across the entire project.

Keep exactly one cumulative metadata ledger with one row per durable isolate/marker ID. It owns `partner_id`, `selected_for_genome_sequencing`, and `already_sequenced`; chromatogram run IDs do not belong in it. Keep a separate read map under each partner/batch, for example `UoG/UoG_01/ab1_mapping.csv`, which maps every physical trace filename to its durable isolate ID, direction, and `processing_mode`. Duplicate ledger IDs, partner mismatches, missing traces, and traces assigned to more than one isolate are Onboarding errors.

Onboarding reports only actionable errors and warnings. Normalised submission/read-map tables omit optional columns that are empty throughout the submitted batch.

---

### `branchmanager paper-trail` (AB1 conversion and Merge Meeting)

Convert Sanger AB1 chromatograms or already-basecalled primer reads into a trimmed FASTA for the Performance Review. When multiple reads belong to the same isolate, for example `27F` and `907R`, BranchManager orients reverse-primer reads and builds a quality-aware overlap consensus.

```bash
branchmanager paper-trail \
  --input ab1_reads/ \
  -o paper_trail_out \
  --min-quality 20 \
  --min-mean-quality 20 \
  --min-length 800 \
  --min-overlap 40

branchmanager performance-review \
  --input paper_trail_out/assembled.fasta \
  --partner-metadata new_sequences_metadata.tsv \
  --db project.db \
  --dataset Batch1 \
  --ref gtdb_r232_bac_arch_ssu_reps.fna \
  -o batch1_out
```

If filenames are structured like `Iso001_27F.ab1` and `Iso001_907R.ab1`, BranchManager can infer the read information. Production partner submissions should nevertheless use one explicit `--sample-map` per batch, preferably with one row per physical read:

```tsv
sequence_id	dataset	read_file	primer	direction	processing_mode
Iso001	UoG_01	well_A01.ab1	27F	forward	assemble
Iso001	UoG_01	well_A02.ab1	907R	reverse	assemble
Iso002	UoG_01	well_B01.ab1	27F	forward	best_read
```

Segmented PacBio HiFi 16S imports use `vsearch --cluster_fast` inside kinnex. `branchmanager pacbio-16s-import` exposes `--threads`, `--vsearch-strand`, `--vsearch-query-cov`, `--vsearch-maxaccepts`, and `--vsearch-maxrejects`, and `branchmanager mailroom --technology pacbio` forwards the same controls with `--pacbio-...` prefixes when it automatically runs kinnex after validating the FASTQ map.

Multiple rows may share the same `sequence_id` when an isolate has multiple primer reads. Relative paths are resolved from the batch-map location. A wide one-row-per-isolate representation is also accepted when laboratories naturally supply separate primer columns:

```tsv
isolate_id	27F	907R	processing_mode
Iso001	well_A01.ab1	well_A02.ab1	assemble
Iso002	well_B01.ab1	well_B02.ab1	best_read
```

Run it with:

```bash
branchmanager paper-trail --sample-map sample_reads.tsv -o paper_trail_out
```

Onboarding writes `normalised_read_map.tsv` as the validated hand-off to Paper Trail. It is a generated run artefact, not another source ledger and not a file users should maintain.

`assemble`/`merge`/`consensus` orients the primer reads and tries to build one longer sequence. `best_read`/`highest_quality`/`select_best`/`independent` converts each read independently and writes only the highest-quality passing read for that isolate.

BranchManager applies the same versioned Sanger QC policy in `interview`, `paper-trail`, and `assistant`:

- `--min-quality` is a Phred cutoff used for Mott-style end trimming.
- `--mask-quality` masks internal bases below Q20 to `N` before assembly; masking is reported but does not by itself force manual review.
- Primer sequences are removed only after a confident IUPAC-aware leading match; customise them with repeatable `--primer-sequence NAME=SEQUENCE`.
- Mixed chromatogram peaks are measured from `PLOC` and four `DATA9`-`DATA12` dye channels. `--secondary-peak-ratio` and `--max-mixed-peak-percent` control the retained-region gate.
- Overlap consensus bases use posterior base probabilities from both Phred observations; qualities are not added as if they were independent certainty scores.
- `--screen-ref` optionally classifies each primer read independently. Family/genus discordance triggers explicit manual review and reports the differing read-level assignments; it is not a QC failure by itself.
- Final sequences must be at least 800 bp. Individual primer reads may be at least 300 bp so complementary reads can assemble into a valid final marker.
- Ambiguous bases use a tiered rule: more than 3% requires manual review and more than 5% fails QC by default.
- `--min-mean-quality`, expected-error limits, ambiguity, internal low-quality runs, mixed peaks, and overlap conflict density determine `PASS_HIGH_CONFIDENCE`, `PASS_WITH_WARNINGS`, or `FAIL_QC`.
- Final `FAIL_QC` sequences are withheld from `assembled.fasta` and listed as `RESEQUENCE`.
- Final `FAIL_QC` sequences and failed reads are retained under `failed_qc_sequences/` for manual review.
- `PASS_WITH_WARNINGS` sequences are included but listed as `MANUAL_REVIEW`.
- Visual reports are automatically split into numbered PNG pages before they exceed 2400 pixels high. Adjust the ceiling with `--max-report-image-height` (minimum 600 pixels).

The defaults follow Phred error probabilities and published Sanger guidance that Q20 is a reliable base call and that, as a general rule, trimmed sequence should contain less than 5% ambiguous bases. The 3% review boundary is deliberately more conservative for phylogenetic candidate selection. See [Ewing and Green 1998](https://doi.org/10.1101/gr.8.3.186) and [Crossley et al. 2020](https://doi.org/10.1177/1040638720905833).

Outputs:

| File | Description |
|---|---|
| `assembled.fasta` | One trimmed/assembled sequence per isolate, suitable for `branchmanager performance-review --input` |
| `failed_qc_sequences/failed_final_sequences.fasta` | Final isolate consensus/best-read sequences that failed final QC |
| `failed_qc_sequences/failed_read_sequences.fasta` | Individual read sequences that failed read-level QC, oriented when direction is known |
| `failed_qc_sequences/failed_qc_manifest.tsv` | One row per failed isolate, combining the final outcome with read IDs, source files, read-failure evidence, and the best recoverable read |
| `failed_qc_sequences/failed_read_manifest.tsv` | One row per failed physical read with trimming and QC evidence; kept separate to avoid duplicate isolate rows |
| `failed_qc_sequences/failed_qc_guide.txt` | Plain-language explanation of failure reason codes and the distinction between isolate- and read-level records |
| `trimmed_oriented_reads.fasta` | Individual reads after quality trimming and primer-direction orientation |
| `raw_reads.fasta` | Raw base calls extracted from AB1 or input sequence files |
| `read_qc.tsv` | Per-read trimming, quality, expected error, length, and filter status |
| `per_base_error.tsv` | Per-base quality/error probability table with left/right trim and retained-base status |
| `visual_reports/read_error_profiles/read_error_profiles_page_*.png` | Paginated per-read quality/error profiles showing retained trim windows |
| `visual_reports/trace_chromatograms/trace_chromatograms_page_*.png` | Paginated dye-channel chromatograms with retained windows and mixed-peak evidence |
| `read_taxonomy_concordance.tsv` | Independent primer-read classifications, common comparison rank, `read_id=taxon` assignments, and within-isolate agreement when `--screen-ref` is used |
| `assembly_report.tsv` | Per-isolate assembly status, overlap identity, conflicts, unmerged reads, contributing read IDs, and any read-level taxonomy disagreement with the compared rank and assignments |
| `assembly_read_placements.tsv` | Per-read consensus coordinates, aligned blocks, and whether the read contributed to the selected consensus |
| `resequence_recommendations.tsv` | Per-isolate `ACCEPT`, `MANUAL_REVIEW`, or `RESEQUENCE` decision with reason codes, taxonomy-concordance evidence, and suggested action |
| `marker_review_template.tsv` | Pre-filled rows for manual-review markers, including conflicting read-level taxonomy assignments; complete `decision`, `reviewer`, and `notes`, then provide it as `--marker-review` |
| `paper_trail_qc_policy.tsv` | Versioned thresholds actually used for the run, for reproducibility |
| `visual_reports/assembly_overviews/assembly_overview_page_*.png` | Paginated per-isolate overviews with reads placed on consensus coordinates, contribution status, and assembly diagnostics |
| `visual_reports/visual_report_manifest.tsv` | Page index with report type, record range, dimensions, and continuation notes |
| `paper_trail_summary.txt` | Short run summary |
| `run_manifest.json` / `.tsv` | Input checksums, software/tool versions, thresholds, stages, outputs, and final status |

Supported inputs are `.ab1`, `.abi`, `.fasta`, `.fa`, `.fna`, `.fastq`, and `.fq`, with `.gz` accepted for AB1/ABI, FASTA, and FASTQ files.

---

### `branchmanager performance-review`

Process new sequences against the baseline; score novelty and update the phylogenetic tree.

```bash
branchmanager performance-review \
  --input new_sequences.fasta \
  --db project.db \
  --dataset Batch1 \
  --ref gtdb_r232_bac_arch_ssu_reps.fna \
  --previous-review filing_cabinet_out \
  -o batch1_out \
  --threads 10 \
  --collapse
```

| Parameter | Required | Default | Description |
|---|---|---|---|
| `--input` | ✓ | — | FASTA file of new sequences to analyse |
| `--db` | ✓ | — | Path to the BranchManager SQLite database |
| `-o / --out` | ✓ | — | Output directory (assessment TSV, novelty metrics, tree, iTOL files) |
| `--dataset` | ✓ | — | Label for this batch (used in iTOL dataset-membership strip) |
| `--ref` | | — | Reference FASTA for classification and tree orientation |
| `--previous-review` | | — | Previous Filing Cabinet or Performance Review output directory used to seed an incremental MSA. When the same `-o` directory is reused, `tree/current_alignment.fasta` is detected automatically |
| `--taxa` | | — | TSV mapping reference IDs to lineages |
| `--taxa-assignments` | | — | Pre-computed taxonomy for the input sequences |
| `--partner-metadata / --sequencing-metadata` | Performance Review | — | Cumulative CSV/TSV ledger with sequence IDs, partner acronyms, optional `selected_for_genome_sequencing`, and required `already_sequenced` status |
| `--shorten-ids / --no-shorten-ids` | | `--no-shorten-ids` | Preserve input headers exactly by default; use `--shorten-ids` only when compact generated IDs are desired |
| `--min-len` | | `800` | Minimum sequence length to retain (bp) |
| `--max-n-percent` | | `5.0` | Maximum percentage of ambiguous (N) bases allowed; matches Paper Trail/Interview final-sequence QC |
| `--marker-qc` | | auto | Paper Trail/Merge Meeting `assembly_report.tsv`; auto-discovered beside the FASTA |
| `--marker-review` | | — | Reviewed accept/reject decisions for warning or unverified marker evidence |
| `--accept-unverified-marker-qc` | | off | Explicit, audited acceptance of independently validated FASTA without Paper Trail provenance |
| `--chimera-ref` | | primary ref | Curated chimera-free marker reference used by reference UCHIME |
| `--skip-chimera-check` | | off | Explicitly omit UCHIME; affected isolates remain review-required |
| `--collapse` | | off | Collapse near-identical same-taxonomy sequences for the tree |
| `--collapse-threshold` | | `99.8` | Identity threshold (%) for collapsing |
| `--sequence-domain` | | `bacteria` | Domain/profile to process: `bacteria`, `archaea`, `fungi`, or `mixed`/`all`/`none` to disable filtering. Run archaea/fungi separately with matching `--ref`, `--alt-ref`, `--baseline-fasta`, `--previous-review`, and `--anchors` |
| `--phylum` | | — | Filter iTOL output to a specific phylum (does not affect novelty scoring) |
| `--target` | | — | FASTA to measure novelty against instead of the DB |
| `--baseline-fasta` | | — | Baseline/context FASTA to load before evaluating, e.g. Hungate |
| `--baseline-dataset` | | `Baseline` | Dataset label for `--baseline-fasta` and default cultured-baseline novelty pool |
| `--novelty-baseline-dataset` | | — | Existing DB dataset to include in the baseline novelty pool; repeatable |
| `--baseline-shorten-ids / --no-baseline-shorten-ids` | | `--no-baseline-shorten-ids` | Preserve baseline IDs exactly by default |
| `--force-rebuild` | | off | Force a full tree rebuild from scratch |
| `--anchors` | | bundled | Custom anchor FASTA for tree scaffolding |
| `--threads` | | `4` | CPU threads |
| `--neighbourhood-format` | | `png` | Local-clade figure format; PNG is the only supported output |
| `--user-colours` | | — | CSV mapping sequence IDs to custom hex colours for iTOL |
| `--group-phyla SPEC` | | — | Group phyla into a single colour in iTOL (repeatable) |
| `--functional` | | — | TSV file mapping sequence IDs to functional attributes (first column = ID; subsequent columns = attributes). Generates one iTOL file per column (DATASET_BINARY / DATASET_SIMPLEBAR / DATASET_COLORSTRIP). |

### Rolling project runs

Use one persistent SQLite database for the project and give each partner submission a unique `--dataset` label. The input FASTA may contain only the genuinely new isolates; `--partner-metadata` may be a cumulative table containing both new and previously stored partner IDs, so changed genome-selection flags are applied before the collection is reassessed.

For an auditable history, use a new output directory for every Performance Review and pass the preceding review with `--previous-review`. Reusing the same output directory is also supported and automatically resumes from `tree/current_alignment.fasta`, but replaces that directory's previous reports. Keep reference-database versions, domain, QC settings, collapse settings, anchors, and tree method constant when comparing reviews. Do not use `--force-rebuild` unless a deliberate full reanalysis is required.

Sequence IDs are persistent keys. Resubmitting an existing ID with the same sequence is allowed; resubmitting it with a different sequence is rejected rather than silently changing the project record. External-reference and cultured-baseline evidence should remain stable when inputs and settings are unchanged. Project crowding, nearest-project hit, genome-collection coverage, pangenome gap, selection-set role, and recommendation are deliberately recalculated because new isolates and updated WGS commitments change those questions.

Incremental runs retain the old MSA columns and add new sequences with MAFFT. The tree builder still estimates a new tree from the expanded alignment, so small changes in old topology or branch lengths remain scientifically possible. Use the preceding Performance Review directory as `--previous-review`, keep parameters/reference versions fixed, inspect `assessment/decision_changes.tsv`, and reserve `--force-rebuild` for deliberate recalibration. Strictly fixed old placements require a validated fixed-backbone phylogenetic-placement workflow and are not claimed by BranchManager.

Domain/profile handling:

BranchManager defaults to `--sequence-domain bacteria` for Filing Cabinet and Performance Review. This keeps bacterial 16S runs clean by filtering non-bacterial assignments before DB insertion and tree building where taxonomy is available. Process archaea and fungi as separate reviews with their own DB, outputs, baselines, references, and anchors:

```bash
branchmanager performance-review ... --sequence-domain archaea --ref archaeal_16s_refs.fasta --previous-review archaea_filing_cabinet -o archaea_review
branchmanager performance-review ... --sequence-domain fungi --ref fungal_its_or_18s_refs.fasta --anchors fungal_anchors.fasta -o fungi_review
```

Use `--sequence-domain mixed` when you intentionally want to keep all domains in one run.

---

### `branchmanager org-chart`

Extract all sequences matching a given taxon from the DB and build a focused phylogenetic tree for that group only.

**Fast path** (recommended): if `--from-dir` points to a directory containing `current_alignment.fasta`, sequences are sliced from the pre-built MSA and only FastTree is run — seconds to minutes for any sized group.

**Slow path**: if no existing alignment is found, a full MAFFT + FastTree build is performed.

```bash
# Domain-level (auto-detected keyword)
branchmanager org-chart --db project.db --taxon archaea      --from-dir filing_cabinet_out -o archaea_out
branchmanager org-chart --db project.db --taxon bacteria     --from-dir filing_cabinet_out -o bacteria_out

# Phylum — plain name (rank auto-detected) or GTDB-prefixed
branchmanager org-chart --db project.db --taxon Bacteroidota       --from-dir filing_cabinet_out -o bact_out
branchmanager org-chart --db project.db --taxon p__Bacillota       --from-dir filing_cabinet_out -o firm_out

# Family
branchmanager org-chart --db project.db --taxon f__Lachnospiraceae --from-dir filing_cabinet_out -o lachno_out

# Genus
branchmanager org-chart --db project.db --taxon g__Ruminococcus    --from-dir filing_cabinet_out -o rumino_out
```

Accepted taxon formats:

| Input | Detected rank | Notes |
|---|---|---|
| `archaea` / `bacteria` | domain | Auto-matched case-insensitively |
| `Bacillota` | phylum (fallback) | No prefix → defaults to phylum |
| `p__Bacillota` | phylum | GTDB prefix auto-detected |
| `f__Lachnospiraceae` | family | |
| `g__Ruminococcus` | genus | |
| `d__Archaea` | domain | Explicit GTDB domain prefix |

| Parameter | Required | Default | Description |
|---|---|---|---|
| `--db` | ✓ | — | Path to the BranchManager SQLite database |
| `-o / --out` | ✓ | — | Output directory |
| `--taxon` | ✓ | — | Taxon to extract (see table above) |
| `--rank` | | `auto` | Override rank detection: `domain` / `phylum` / `family` / `genus` / `species` |
| `--from-dir` | | — | Existing Filing Cabinet or Performance Review output directory with `current_alignment.fasta` or `tree/current_alignment.fasta` (fast path) |
| `--ref` | | — | Reference FASTA for orientation correction (slow path only) |
| `--anchors` | | bundled | Custom anchor FASTA |
| `--threads` | | `4` | CPU threads |
| `--min-seqs` | | `3` | Minimum matching sequences required to build a tree |
| `--no-tree` | | off | Skip tree building; only write taxonomy TSV and iTOL colour files |
| `--group-phyla SPEC` | | — | Group phyla into a single colour in iTOL (repeatable) |
| `--functional` | | — | TSV file mapping sequence IDs to functional attributes (first column = ID; subsequent columns = attributes). Generates one iTOL file per column (DATASET_BINARY / DATASET_SIMPLEBAR / DATASET_COLORSTRIP). |

Org Chart outputs:

| File | Contents |
|---|---|
| `org_chart_tree.nwk` | Focused newick tree (anchor-free, nodes labelled `NODE####`) |
| `org_chart_alignment.fasta` | Filtered alignment slice used for the tree |
| `org_chart_combined_taxonomy.tsv` | ID → taxonomy → confidence for matched sequences |
| `org_chart_sequence_list.tsv` | ID, taxonomy, confidence, dataset for matched sequences |
| `itol_phylum_colours.itol` | iTOL colour strip by phylum |
| `itol_dataset_membership.itol` | iTOL strip showing which dataset each sequence came from |

---

### `branchmanager label-maker`

Regenerate all iTOL colour files from taxonomy already stored in the DB — without re-classifying or rebuilding the tree. Useful when changing phylum groupings.

```bash
branchmanager label-maker \
  --db project.db \
  --out filing_cabinet_out \
  --group-phyla archaea \
  --group-phyla "Bacillota,Bacillota_I,Bacillota_A"
```

| Parameter | Required | Default | Description |
|---|---|---|---|
| `--db` | ✓ | — | Path to the BranchManager SQLite database |
| `-o / --out` | ✓ | — | Output directory (use your Filing Cabinet or Performance Review output directory) |
| `--include-datasets` | | all | Comma-separated dataset names to include |
| `--sequence-domain` | | — | Include only sequences from this domain/profile |
| `--group-phyla SPEC` | | — | Group phyla into a single colour (repeatable) |
| `--functional` | | — | TSV file mapping sequence IDs to functional attributes (first column = ID; subsequent columns = attributes). Generates one iTOL file per column (DATASET_BINARY / DATASET_SIMPLEBAR / DATASET_COLORSTRIP). |

---

## Phylum grouping for iTOL (`--group-phyla`)

Available on all four subcommands. Groups multiple phyla into a single colour entry in the iTOL legend.

| Spec format | Effect |
|---|---|
| `archaea` | All archaeal phyla (detected by `d__Archaea` domain) → one colour labelled **Archaea** |
| `bacteria` | All bacterial phyla → one colour labelled **Bacteria** |
| `"Bacillota,Bacillota_I,Bacillota_A"` | These three phyla → one colour; label = first name (`Bacillota`) |
| `"Firmicutes:Bacillota,Bacillota_I"` | These two phyla → one colour labelled **Firmicutes** |

Multiple `--group-phyla` arguments are independent and additive:

```bash
branchmanager performance-review ... \
  --group-phyla archaea \
  --group-phyla "Bacillota,Bacillota_I,Bacillota_A" \
  --group-phyla "Bacteroidota,Bacteroidota_A"
```

---

## Multiple dataset stacking

Datasets accumulate in the DB. Each Performance Review sees the growing baseline and project collection:

```bash
# Step 1 — baseline
branchmanager filing-cabinet --fasta hungate.fasta --db project.db --dataset Hungate ...

# Step 2 — first batch: novelty scored against Hungate
branchmanager performance-review --input batch1.fasta --db project.db --dataset Batch1 ...

# Step 3 — second batch: novelty scored against Hungate + Batch1
branchmanager performance-review --input batch2.fasta --db project.db --dataset Batch2 ...
```

---

## Clustering and tree redundancy reduction (`--collapse`)

When `--collapse` is enabled, BranchManager groups sequences sharing ≥ `--collapse-threshold` identity and the same taxonomy, keeping only one **cluster representative** per group for tree building.

#### Column Explanation

| Column | Meaning |
|---|---|
| ID | User-supplied sequence ID (preserved unless ID shortening is explicitly requested) |
| Taxonomy | Full GTDB lineage assigned by the classifier |
| BestHit | Closest reference genome accession (VSEARCH best hit) |
| ClassificationIdentity | % identity to the BestHit reference (VSEARCH alignment) |
| ClassificationConfidence | Confidence of the taxonomy assignment (from the taxa TSV); NA when taxonomy is parsed directly from reference FASTA headers (no confidence column available) |
| NearestHit | Closest sequence among YOUR previously submitted sequences (Filing Cabinet + prior Performance Reviews) |
| NearestIdentity | % identity to NearestHit |
| MatchesGE99 / GE97 / GE95 | Count of YOUR submitted sequences within 99% / 97% / 95% identity |
| NoveltyScore | 100 − NearestIdentity (higher = more novel vs. your collection) |
| Crowding | Neighbourhood density: crowded / moderate / sparse based on how many of your sequences are nearby |
| SequencingPriority | HIGH / MEDIUM / LOW — suggested priority for follow-up based on novelty + crowding |
| Reference* | Parallel nearest hit, identity, score, crowding, and priority against the selected external reference FASTA, usually GTDB |
| InTree | Yes = entered the phylogenetic tree; No = excluded (see ClusterRepresentative) |
| ClusterRepresentative | `self` = this sequence is in the tree; an ID = represented by that leaf after optional collapse; `duplicate` = retained isolate omitted from the final tree as an exact marker duplicate |
| ClusterSize | Total sequences in this cluster (1 = singleton) |
| ClusteredMembers | Semicolon-separated IDs of OTHER sequences collapsed under this representative |
| PlacementFlags | Warnings: LOW_CLASSIFICATION_IDENTITY, LOW_NEAREST_IDENTITY, NOVEL_BUT_ASSIGNED, etc. |

### `novelty_metrics.tsv`

This table keeps the novelty lenses separate:

- `Hungate*`: nearest hit, identity, query coverage, novelty, and density against priority Hungate baselines.
- `SecondaryBaseline*`: the same evidence against secondary cultured-rumen baseline datasets.
- `CulturedRumen*`: closest evidence across Hungate and secondary baseline tiers combined.
- `Project*`: nearest hit and density against all partner candidates accumulated across runs, including the current collection but excluding each query's self-hit.
- `Reference*`: nearest hit and density against the selected external reference FASTA supplied with `--ref`, usually GTDB.
- `GenomeCollection*` / `Pangenome*`: rolling genome coverage. Every baseline isolate counts because its genome is available; partner isolates count once selected. The default target is nine committed genomes per exact GTDB species or unresolved local clade.
- `SelectionGroupType`: `HUNGATE_BASELINE_EXTENSION` means a Hungate genome anchors the exact GTDB species, `SECONDARY_BASELINE_EXTENSION` means only secondary cultured-rumen genomes anchor it, and `CANDIDATE_ONLY_GROUP` has no baseline-genome anchor.
- `BaselineExtension*`: membership gate for a baseline-pangenome extension. The candidate and nearest cultured-rumen baseline must have the same exact GTDB species, with >=98.65% 16S identity across >=95% of the query by default. A failed gate is `PANGENOME_BOUNDARY_REVIEW`, not an automatic rejection: it may represent a separate candidate lineage.
- `BaselineRedundancy*`: hard eligibility gate for uncommitted candidates. By default, a nearest cultured-rumen hit at >=99.8% identity across >=95% of the query is reported as `BASELINE_REDUNDANT` and receives no panel rank.
- `SelectionDiversityDistance`: marginal patristic distance from baseline and already committed genome markers when tree distances are available. This drives farthest-first diversity capture; cultured-baseline, project, and GTDB-reference divergence provide the fallback, with MWL evidence used as an additional tie-break signal.

A species represented by one baseline genome therefore starts at `1/9`, leaving eight primary genome slots. Eligible partner isolates are ranked to extend that baseline pangenome; additional ranked isolates can be retained as extraction-failure/diversity backups. MWL evidence can order eligible isolates but cannot override the species/coverage boundary or the near-identical baseline exclusion.

---

## All output files

### Filing Cabinet outputs

| File | Description |
|---|---|
| `current_tree.nwk` | Backbone phylogenetic tree (newick, nodes labelled `NODE####`) |
| `current_alignment.fasta` | Full multiple sequence alignment (includes anchor sequences) |
| `filing_cabinet_combined_taxonomy.tsv` | ID → taxonomy → confidence for all registered baseline sequences |
| `taxonomy.tsv` | Raw classifier output (ID, best-hit, identity, taxonomy, confidence) |
| `itol_phylum_colours.itol` | iTOL colour strip by phylum |
| `itol_family_colours.itol` | iTOL colour strip by family |
| `itol_genus_colours.itol` | iTOL colour strip by genus |
| `filing_cabinet_dataset.itol` | iTOL strip marking all sequences with the dataset colour |
| `filing_cabinet_id_map.tsv` | Short ID → original FASTA header mapping |
| `filing_cabinet_collapsed_map.tsv` | Cluster representative → taxonomy → count |
| `filing_cabinet_collapsed_members.tsv` | Member → representative mapping |
| `tree_build_warnings.tsv` | Warnings about sequence quality or alignment issues |
| `tree_orientation_summary.tsv` | Per-sequence orientation audit (forward / RC / unknown) |
| `OUTPUT_EXPLANATIONS.tsv` | Manifest describing each output file |

### Performance Review and Hiring Panel outputs

| File | Description |
|---|---|
| `performance_review_dashboard.html` | Compact linked view of the current Hiring Panel recommendations |
| `assessment/sequence_assessment.tsv` | **Current-dataset full audit table.** Per-sequence novelty, taxonomy, crowding, priority, clustering, MWL matches, and placement flags for only the dataset supplied to this Assistant/Performance Review run |
| `assessment/selection_summary.tsv` | **Current-dataset SAB decision table.** Recommendation, evidence quality, component novelty evidence, same-species genome coverage, candidate-set role, rationale, and local-tree link |
| `assessment/sequencing_sets.tsv` | **Current-dataset nine-member diversity plan.** Prior datasets and baselines inform coverage and diversity, but only current input candidates receive rows in this run |
| `assessment/novelty_metrics.tsv` | Current-dataset novelty and crowding summary; searches use the cumulative baseline and project collection as comparison context |
| `assessment/neighbourhoods/clade_*.png` | Labelled local phylogenetic neighbourhoods (default). Nearby assessed isolates are grouped into one figure rather than duplicated across figures |
| `assessment/neighbourhoods/clade_*_pairwise_pident.tsv` | Complete long-form MSA percent-identity table for every pair of displayed tree leaves, including compared-column counts and the identity definition |
| `assessment/neighbourhoods/neighbourhood_manifest.tsv` | Maps every assessed sequence to its image and pident table, including the P1 identity anchor, forced nearest-baseline hits, assessed isolates, baseline leaves, and already-sequenced genomes shown |
| `assessment/mwl_matches.tsv` | Most Wanted List hits when `--mwl` is supplied |
| `assessment/cluster_summary.tsv` | Cluster-level prioritisation report when clustering/tree reports are available |
| `assessment/clusters.csv` | One consolidated membership table containing all clusters and all member isolates; replaces the former one-file-per-cluster directory |
| `assessment/backup_candidates.tsv` | Ranked alternative isolates within clusters when a primary candidate cannot be sequenced |
| `baseline/baseline_hits.tsv` | Nearest-hit report against Hungate or other provided baseline datasets |
| `baseline/nearest_baseline_hits_raw.tsv` | Raw nearest-hit output used for baseline novelty scoring |
| `taxonomy/<DB>.tsv` | Taxonomic assignment report for each reference database, e.g. `taxonomy/GTDB.tsv`, `taxonomy/GG2.tsv` |
| `taxonomy/all_databases.tsv` | Multi-database assignment summary |
| `taxonomy/tree_taxonomy.tsv` | ID → taxonomy → confidence table used for tree/iTOL metadata |
| `tree/current_tree.nwk` | Cumulative project-context tree incorporating baseline, prior partner datasets, and the current dataset |
| `tree/current_alignment.fasta` | Cumulative MSA used to build the project-context tree |
| `tree/tree_build_warnings.tsv` | Tree-quality warnings |
| `itol/phylum.itol` | iTOL colour strip by phylum |
| `itol/family.itol` | iTOL colour strip by family |
| `itol/genus.itol` | iTOL colour strip by genus |
| `itol/dataset_membership.itol` | iTOL strip showing which dataset each sequence belongs to |
| `itol/novelty.itol` | iTOL strip showing nearest-hit novelty |
| `ids/user_id_map.tsv` | Short ID → original FASTA header mapping for this run |
| `intermediate/` | QC, optional collapse, and classifier scratch outputs retained for debugging; exact marker duplicates retain separate isolate IDs in assessment reports |
| `logs/branchmanager.log` | Run log |

BranchManager keeps iTOL `DATASET_COLORSTRIP` files, one per metadata type. Older `TREE_COLORS` branch/range files and symbol-strip variants are removed because they encoded the same metadata in additional visual styles.

### `selection_summary.tsv`

This is the board-facing table for scientific advisory board discussions. It avoids an opaque adjusted score and keeps the evidence components visible: cultured-baseline novelty, rolling project coverage, GTDB-reference divergence, rank-aware MWL evidence, exact same-species genome counts, marker evidence quality, candidate-set role, and local-tree figure.

`SelectedForGenomeSequencing` and `GenomeAlreadySequenced` keep pending commitments distinct from completed genomes. `SelectedPendingGenomesSameSpecies` contributes to `CommittedGenomesSameSpecies` but not to nearest-available-genome identity.

The decision labels are:

| Decision | Meaning |
|---|---|
| `PRIORITISE - SET PRIMARY` | Fills one of the missing genomes needed to reach the per-species pangenome target |
| `RESERVE - SET BACKUP` | Additional phylogenetically spread isolate retained for extraction failure and strain-diversity capture |
| `STRONG CANDIDATE` / `SECONDARY CANDIDATE` | Useful evidence, but not currently assigned a primary/backup place in the working set |
| `SECONDARY - STRAIN DIVERSITY` | The numerical target is met, but the isolate adds a ranked diversity direction not represented by baseline/committed markers |
| `REVIEW - PANGENOME BOUNDARY` | The species, identity, or coverage evidence does not justify placing the isolate in the baseline-pangenome extension; review it as a possible separate lineage |
| `EXCLUDE - BASELINE REDUNDANT` | >=99.8% identity to a cultured baseline marker across >=95% query coverage; retained in reports but excluded from ranking |
| `LOWER PRIORITY - TARGET MET` | Available genomes plus committed pending selections meet the requested exact-GTDB-species target |
| `REVIEW BEFORE SELECTION` | Marker classification, QC, disagreement, or required comparison evidence needs review |
| `ALREADY SELECTED - GENOME PENDING` | The isolate is already committed to sequencing but no usable genome is available yet |
| `ALREADY SEQUENCED` | The current isolate already has an available genome and is not a new sequencing recommendation |

### Project-wide expansion rounds

The default Performance Review targets nine committed genomes per exact GTDB species, or per local phylogenetic clade when species assignment is unresolved. It writes up to nine ranked eligible partner candidates per group. Baseline and completed/pending partner genomes determine the remaining target gap, while candidates outside that gap remain ranked as backups or post-target diversity options.

Near-identical cultured-baseline matches are excluded only when both identity and alignment extent support the claim: >=99.8% marker identity and >=95% query coverage by default. This prevents a short high-identity fragment from being treated as redundant. Diversity is ranked first using marginal tree distance from baseline and committed genomes where available, then baseline/project/reference divergence and phylogenetic isolation. MWL rank and score add priority among otherwise comparable diversity choices but never override the baseline-redundancy gate.

After partner submissions have accumulated and sequencing statuses have been updated, run a Quarterly Review to choose the next tranche across the whole project:

```bash
branchmanager quarterly-review \
  --db project.sqlite \
  --genome-budget 24 \
  --backups-per-primary 1 \
  --tree runs/final/tree/current_tree.nwk \
  --alignment runs/final/tree/current_alignment.fasta \
  --partner-metadata partner_status.tsv \
  -o quarterly_review_01
```

`--genome-budget` is the number of new primary nominations, not including backups. Quarterly Review fills remaining nine-genome coverage gaps first, filters baseline-redundant candidates, then balances diversity across species. Within those tiers it uses marginal tree distance where available, nearest-genome marker identity, cultured-baseline novelty, GTDB-reference context, phylogenetic isolation, and MWL evidence. When `--alignment` is supplied, nearest available-genome identity is recomputed against the current genome collection, so newly completed genomes affect the next round immediately. It does not change `already_sequenced`; recommendations become available genomes only after metadata is updated in a later round.

Every current Performance Review stores its normalised assessment rows in the project database. For an older review made before assessment snapshots were introduced, import its full audit table once:

```bash
branchmanager quarterly-review \
  --db project.sqlite \
  --assessment runs/01_Batch1/assessment/sequence_assessment.tsv \
  --genome-budget 24 \
  --tree runs/01_Batch1/tree/current_tree.nwk \
  -o quarterly_review_01
```

Quarterly Review outputs are:

| File | Description |
|---|---|
| `next_genome_set.tsv` | Current `PRIMARY` nominations and their `BACKUP` isolates |
| `quarterly_review_summary.tsv` | Full audit containing all candidates, already-sequenced isolates, review exclusions, tiers, marginal distances, and reasons |
| `quarterly_review_manifest.tsv` | Round parameters, recommendation counts, and scientific scope |
| `neighbourhoods/clade_*.png` | Round-specific local-clade figures whose stars show this Quarterly Review's primary and backup nominations |

Quarterly Review is marker-gene decision support. Once genomes are available, strain-level expansion should be checked with ANI, phylogenomics, and pangenome structure rather than treating 16S distance as a strain boundary.

### `sequence_assessment.tsv` columns

| Column | Meaning |
|---|---|
| `ID` | Sequence ID supplied by the user; IDs are preserved unless shortening is explicitly requested |
| `GTDBTaxonomy` | Full authoritative GTDB lineage assigned by the classifier |
| `GTDBClassificationHit` | Closest GTDB reference accession used for classification |
| `GTDBClassificationIdentity` | % identity to the classification hit |
| `GTDBClassificationConfidence` | Confidence of the GTDB assignment |
| `BaselineNearestHit` | Closest sequence in the cultured baseline, e.g. Hungate |
| `BaselineNearestHitDataset` | Dataset label for that baseline hit |
| `BaselineNearestIdentity` | % identity to the cultured-baseline hit |
| `BaselineMatchesGE99 / GE97 / GE95` | Count of baseline sequences within 99% / 97% / 95% identity |
| `BaselineNoveltyScore` | 0–100 score; higher = more divergent and less crowded versus cultured isolates |
| `BaselineCrowding` | Baseline neighbourhood density: `crowded` / `moderate` / `sparse` / `isolated` |
| `BaselinePriority` | `HIGH` / `MEDIUM` / `LOW` heuristic from baseline novelty and density |
| `Project*` | Parallel novelty hit, identity, score, crowding, and priority against the rolling partner-candidate collection, excluding self |
| `GTDBReference*` | Parallel nearest hit, identity, score, and crowding against the authoritative GTDB reference |
| `PartnerID` | Partner acronym loaded from `--partner-metadata`, e.g. `QUB` or `UoG` |
| `SelectedForGenomeSequencing` | Whether the project has committed this isolate to sequencing; the genome may still be pending |
| `GenomeAlreadySequenced` | Whether the current partner isolate already has an available genome; a recommendation alone does not set this field |
| `GenomeCollection*` | Nearest hit and density across all baseline genomes plus already-sequenced partner genomes |
| `BaselineGenomesSameAssessmentSpecies` / `SequencedPartnerGenomesSameAssessmentSpecies` | Existing exact-species genome coverage by source; assessment species means GTDB for bacterial/archaeal Performance Reviews |
| `CommittedGenomesSameAssessmentSpecies` / `SelectedPendingGenomesSameAssessmentSpecies` / `PangenomeTarget` / `PangenomeGap` | Rolling completed-genome coverage, pending commitments, and the number of additional selections required |
| `SequencingSet*` | Stable group ID and proposed primary/backup/alternate action for the isolate |
| `LocalNeighbourhoodFigure` | Relative path to the local-clade PNG containing this assessed sequence |
| `TreeContextLeafCount` | Number of tree leaves displayed in that figure; this is display context, not a crowding score |
| `AssessedSequencesInTreeContext` | Number of current assessed isolates sharing the figure |
| `InTree` | `Yes` = in tree; `No` = excluded (see `ClusterRepresentative`) |
| `ClusterRepresentative` | `self`, a representative ID, or `duplicate` |
| `ClusterSize` | Sequences in this cluster |
| `ClusteredMembers` | Other sequences collapsed under this representative |
| `PlacementFlags` | Warning codes (e.g. `LOW_CLASSIFICATION_IDENTITY`) |

---

## Reference inputs — which flag to use

| Scenario | Recommended flags |
|---|---|
| Classify against GTDB reps FASTA | `--ref gtdb.fna --classify` |
| Input FASTA has embedded GTDB lineages in headers | `--taxa-assignments input.fasta` |
| Separate taxonomy TSV for the input sequences | `--taxa-assignments assignments.tsv` |
| GTDB FASTA + separate taxonomy TSV for the reference | `--ref gtdb.fna --taxa gtdb_taxonomy.tsv --classify` |

`--ref` = the reference database used for classification and tree orientation.  
`--taxa-assignments` = pre-computed taxonomy for the *input* sequences themselves.

### Partner sequencing metadata

`branchmanager performance-review` requires `--partner-metadata` / `--sequencing-metadata`. Provide this as a simple sidecar `.csv`, `.tsv`, or gzipped CSV/TSV alongside the FASTA. It must contain:

- A sequence ID column such as `sequence_id`, `isolate_id`, `sample_id`, or `ID`. Values may match IDs in the current FASTA or partner isolates already stored in the same project SQLite database.
- A partner acronym column such as `partner_id`, `partner`, or `partner_acronym`, with values like `QUB` or `UoG`.
- An optional selection-commitment column such as `selected_for_genome_sequencing`. Use `yes` after the project has actually committed that isolate to sequencing.
- An already-sequenced/genome-available column such as `already_sequenced`, `genome_available`, or `genome_sequenced`. This column is required and must be explicit `yes` or `no`.

Example:

```tsv
sequence_id	partner_id	selected_for_genome_sequencing	already_sequenced
Iso001	QUB	yes	no
Iso002	UoG	yes	yes
Iso003	UoG	no	no
```

Set `selected_for_genome_sequencing=yes` only after the advisory/project decision has been made. It reserves that isolate in rolling pangenome commitments but does not put it in the nearest-genome comparison pool. Set `already_sequenced=yes` only when a usable genome is genuinely available; that state does enter WGS coverage and nearest-genome calculations. `PRIMARY` and `BACKUP` are BranchManager recommendations and do not update either factual state automatically.

Keep one cumulative ledger for the project. It may contain rows from earlier submissions even when the current FASTA contains only new sequences. Each Performance Review refreshes matched stored isolates before recalculating commitments, available-genome coverage, and recommendations.

---

## ID shortening

By default, BranchManager preserves the FASTA IDs exactly as supplied. This is especially important for Hungate/baseline datasets and partner-provided isolate IDs.

- `--no-shorten-ids` (default) — keep supplied IDs.
- `--shorten-ids` — generate compact IDs when explicitly requested.
- `--no-baseline-shorten-ids` (default for Performance Review baselines) — keep baseline IDs exactly.
- `--baseline-shorten-ids` — generate compact baseline IDs when explicitly requested.

When IDs are shortened, BranchManager writes an ID map under `ids/`. When IDs are preserved, the map is still useful as an audit trail but should normally be identity-to-identity.

---

## Anchor sequences

Anchor sequences are **invisible scaffolding** constraining phylum-level topology during tree construction. They are pruned from the stored newick after each build and never appear in outputs, iTOL files, or novelty scoring.

The bundled anchor set (`src/branchmanager/data/reference_anchors.fasta`) contains 26 NCBI RefSeq 16S sequences covering major gut/rumen phyla. A companion metadata table (`src/branchmanager/data/reference_anchors.tsv`) explains what each anchor represents, its rumen relevance, and whether it is a core rumen anchor or broader topology scaffold.

| Phylum | Type strain | Accession |
|---|---|---|
| Bacillota | *Ruminococcus albus* 7 | NR_025930 |
| Bacillota | *Clostridium butyricum* ATCC 19398 | NR_074545 |
| Bacillota | *Bacillus subtilis* 168 | NR_027552 |
| Bacillota | *Lactobacillus acidophilus* ATCC 4356 | NR_075051 |
| Bacillota | *Streptococcus equinus* NBRC 12553 | NR_113594 |
| Bacillota | *Butyrivibrio fibrisolvens* D1 | NR_044858 |
| Bacteroidota | *Bacteroides fragilis* ATCC 25285 | NR_041386 |
| Bacteroidota | *Prevotella bryantii* B14 | NR_044825 |
| Bacteroidota | *Porphyromonas gingivalis* ATCC 33277 | NR_040847 |
| Pseudomonadota | *Escherichia coli* K-12 | NR_102804 |
| Pseudomonadota | *Helicobacter pylori* 26695 | NR_073694 |
| Pseudomonadota | *Wolinella succinogenes* DSM 1740 | NR_043184 |
| Actinomycetota | *Bifidobacterium longum* NCC2705 | NR_040783 |
| Actinomycetota | *Streptomyces griseus* ATCC 23345 | NR_043823 |
| Spirochaetota | *Treponema pallidum* str. Nichols | NR_027243 |
| Spirochaetota | *Borrelia burgdorferi* B31 | NR_025890 |
| Fibrobacterota | *Fibrobacter succinogenes* S85 | NR_041558 |
| Fusobacteriota | *Fusobacterium nucleatum* ATCC 25586 | NR_026043 |
| Planctomycetota | *Planctomyces maris* DSM 8797 | NR_043399 |
| Verrucomicrobiota | *Akkermansia muciniphila* ATCC BAA-835 | NR_042817 |
| Thermotogota | *Thermotoga maritima* MSB8 | NR_043084 |
| Deinococcota | *Deinococcus radiodurans* R1 | NR_036779 |
| Cyanobacteriota | *Synechococcus elongatus* PCC 6301 | NR_043317 |
| Archaea (outgroup) | *Methanobrevibacter ruminantium* M1 | NR_044812 |
| Archaea (outgroup) | *Methanobacterium thermoautotrophicum* Marburg | NR_028243 |
| Archaea (outgroup) | *Sulfolobus acidocaldarius* DSM 639 | NR_043325 |

This is a pragmatic rumen/gut scaffold rather than a final rumen-only reference panel. The TSV flags which anchors are core rumen representatives and which are broader topology anchors that can be replaced as better vetted rumen-specific sequences become available.

To use a custom anchor file:
```bash
branchmanager filing-cabinet --anchors /path/to/my_anchors.fasta ...
```
Custom anchor headers must begin with `BRANCHMANAGER_REF_`:
```
>BRANCHMANAGER_REF_MyPhylum accession=NR_XXXXXX source=SILVA138
```

To refresh the bundled anchors from NCBI:
```bash
python scripts/build_anchor_fasta.py --email your@institution.ac.uk
```

---

## Interpreting outputs

### Selection evidence

| Metric | Meaning |
|---|---|
| `CulturedGap` | `LARGE` below 97%, `MODERATE` from 97% to <98.65%, and `SMALL` at >=98.65% against the cultured baseline |
| `ProjectCoverage` | Number of other rolling partner candidates at >=97% identity: uncovered, sparse (1-3), moderate (4-10), or dense (>10) |
| `ReferenceContext` | `HIGH DIVERGENCE` below 94.5%, `MODERATE DIVERGENCE` from 94.5% to <98.65%, or `CLOSE REFERENCE` at >=98.65% |
| `GenomeCoverage` | Exact same-GTDB-species available-genome count and remaining target gap; nearest-genome identity is shown separately as context |
| `EvidenceQuality` | Whether classification identity and placement warnings support using the marker result for selection |

The 94.5% and 98.65% values are commonly used full-length 16S heuristics for genus- and species-range divergence. BranchManager uses them as decision-support categories, not as declarations of a new genus or species. Sequence quality, alignment coverage, marker copy variation, phylogenetic placement, and ultimately genome-based analysis still matter.

Threshold basis: [Yarza et al. (2014), genus and higher-rank 16S boundaries](https://doi.org/10.1038/nrmicro3330) and [Kim et al. (2014), 98.65% 16S/ANI species-demarcation correspondence](https://pubmed.ncbi.nlm.nih.gov/24505072/). Their use in rumen-focused taxonomy is discussed by [Henderson et al. (2019)](https://doi.org/10.7717/peerj.6496), including limitations for unusually diverse genera.

The local-clade images expand around each assessed tree leaf to show a compact context (normally 8-30 leaves). Overlapping contexts are merged when their common clade remains compact. The nearest cultured-baseline hit for each grouped context is forced into the image even when reaching it crosses the normal leaf limit; less informative non-target leaves are pruned first. An orange diamond and `[SEQUENCED]` mark a confirmed available genome. A filled purple star marks the current sequence-next recommendation (`[P1]`, or another primary if more than one genome is missing); outlined purple stars mark recommended backups (`[B2]` and later ranks). `[ALT]` isolates are contextual alternatives, not current recommendations.

Each leaf label reports MSA pident relative to the figure's P1 sequence, and `clade_*_pairwise_pident.tsv` contains all displayed leaf-to-leaf comparisons. MSA pident is defined as identical A/C/G/T bases divided by alignment columns where both sequences contain an unambiguous A/C/G/T base; `ComparableACGTColumns` reports the overlap supporting the value. Terminal overhangs, gaps, and ambiguous bases are excluded rather than being misreported as substitutions. Internal nodes are inferred ancestors without observed marker sequences, so BranchManager does not assign pident to them; branch geometry and the scale bar remain modelled substitutions per site. These plots support visual inspection, while quantitative crowding remains the vsearch `MatchesGE*` count against explicitly named pools.

### Placement flags

| Flag | Meaning |
|---|---|
| `LOW_CLASSIFICATION_IDENTITY` | < 95% identity to best reference hit |
| `LOW_CONFIDENCE` | Classification confidence below threshold |
| `LOW_NEAREST_IDENTITY` | < 95% identity to nearest sequence in your collection |
| `NOVEL_BUT_ASSIGNED` | High novelty score despite a confident taxonomy assignment |

### Tree quality warnings

The tree is a context plot, not absolute proof of novelty. Always pair tree inspection with `sequence_assessment.tsv`. Warnings in `tree_build_warnings.tsv`:

| Warning | Meaning |
|---|---|
| `PARTIAL_16S_SEQUENCES` | Sequences shorter than 1200 bp reduce placement accuracy |
| `HIGH_N_CONTENT` | High ambiguous-base content can distort branch lengths |
| `VERY_SHORT_ALIGNED_FRAGMENTS` | Some aligned rows are mostly gaps after MAFFT |
| `MISSING_REFERENCE_ANCHORS` | Tree was built without topology scaffolding |

If a large `unknown` sector appears in iTOL, check:
- `combined_taxonomy.tsv` or `filing_cabinet_combined_taxonomy.tsv`
- `taxonomy.tsv` (raw classifier output)
- `taxonomy_input_warnings.tsv`

---

## Operational updates and project close-out

Recommendations are not genome facts. Use `status-meeting` for laboratory progress and `records-update` only when genome evidence exists.

```bash
# Laboratory/SAB lifecycle changes
branchmanager status-meeting --db project.sqlite --input isolate_status.tsv -o updates/status_01

# Completed assemblies, with automatic 90% completeness / 5% contamination defaults
branchmanager records-update --db project.sqlite --input genome_results.tsv -o updates/genomes_01

# Re-open the complete collection after the initial target-nine selection phase
branchmanager quarterly-review --db project.sqlite --genome-budget 24 \
  --from-dir runs/latest/03_performance_review_hiring_panel -o quarterly_reviews/round_02

# Final cumulative report after sequencing and genome QC
branchmanager annual-report --db project.sqlite -o final_annual_report
```

`isolate_status.tsv` requires `sequence_id` and `status`; supported states include `RECEIVED`, `TRACE_REVIEW`, `MARKER_QC_PASSED`, `PROPOSED`, `SAB_APPROVED`, `DNA_EXTRACTION_FAILED`, `SEQUENCED`, `GENOME_QC_FAILED`, and `GENOME_QC_PASSED`.

`genome_results.tsv` requires `sequence_id` and `genome_id`/`accession`. Recommended fields are `genome_status`, `completeness`, `contamination`, `gtdb_taxonomy`, `ani_cluster`, and `genome_path`. A `SEQUENCED` row with both quality metrics is automatically assigned genome-QC pass/fail using the configured thresholds. Explicit QC pass values that conflict with supplied metrics are rejected. Only QC-passed genomes update the available genome collection.

### Add genomes sequenced outside the selection workflow

Use `add-external-genomes` to register a project-level baseline genome collection. Supply one row per isolate/genome. Genome-level taxonomy is retained even when the isolate has no 16S marker. If marker sequences are available, pass a FASTA with headers matching `sequence_id`:

```bash
branchmanager add-external-genomes --config configs/rumen_gateway.json --db project.sqlite \
  --input external_genomes.tsv --marker-fasta external_16s.fasta \
  --dataset ExternalArchive --baseline-tier secondary -o imports/external_archive
```

Required columns are `sequence_id` and `genome_id` or `accession`. Optional fields include `gtdb_taxonomy`, `genome_qc_pass`, completeness/contamination, `ani_cluster`, and per-row `dataset`/`baseline_tier`. Genome availability is recorded as confirmed. Markerless isolates contribute genome/taxonomy coverage and are omitted from 16S similarity searches and trees.

## Benchmarking recommendations

Before using selection output as a scientific conclusion, benchmark it against independently adjudicated outcomes on held-out cohorts. The repository includes a schema and evaluator in [`examples/benchmark_labels.template.tsv`](examples/benchmark_labels.template.tsv) and [`scripts/benchmark_selection.py`](scripts/benchmark_selection.py). Include all eligible candidates for each case, label the predeclared outcome independently of BranchManager, and include competing methods under the same `case_id` values. Evaluate multiple selection budgets (`precision@k`, `recall@k`) and overall rank quality (`mean average precision`); report cohort-level results and uncertainty, not just pooled values.

```bash
python scripts/benchmark_selection.py --input adjudicated_rankings.tsv \
  --out benchmark_summary.tsv --k 1 5 10
```

The output includes case-level bootstrap 95% percentile intervals (2,000 resamples by default; set `--bootstrap 0` to disable). This evaluator summarizes rankings; it does not supply validation data or establish biological validity. A journal submission still needs real, documented, held-out collection data; a comparator; sensitivity analyses for thresholds/reference versions; and error analysis for QC failures, unresolved taxonomy, and missing or biased references. The validation protocol and scientific scope checklist are in [collection profiles and scope](docs/collection-profiles-and-validation.md).

Every Performance Review, Quarterly Review, and Records Update works on a locked staged database and atomically publishes the result after validation. Annual Report writes an HTML dashboard, isolate and genome ledgers, workflow history, and the latest decision-change audit.

Office-stage reports are named `onboarding_report.tsv`, `onboarding_summary.json`, `status_meeting_report.tsv`, `records_update_report.tsv`, `annual_report.html`, `it_desk_report.tsv`, and `it_desk_summary.json`.

Before a production run:

```bash
branchmanager it-desk --db project.sqlite --ref gtdb_ssu_reps.fna.gz \
  --tree-method fasttree --strict -o it_desk
```

## What BranchManager does

BranchManager is aimed at ranking marker-gene sequence evidence for isolate follow-up. It helps identify lineages that may have been missed because of primer bias, sparse reference coverage, taxonomy lag, or conservative filtering. Many targets are not new in nature — they are often **new to the reference record** or **underrepresented in existing collections**.

That is why BranchManager combines reference-aware classification with novelty scoring, Sanger QC, baseline/reference comparisons, partner metadata, and warning layers, rather than treating every long branch as a discovery.
