# HG changeset patch
# User matces
# Date 1307479841 14400
# Node ID cdd489d987663a3e1a886cd73b2602a055e44f96
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
diff -r 000000000000 -r cdd489d98766 carpet-src-1/COPYING
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/COPYING Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ 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.
+
+
+ Copyright (C)
+
+ 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 .
+
+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:
+
+ Copyright (C)
+ 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
+.
+
+ 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
+.
diff -r 000000000000 -r cdd489d98766 carpet-src-1/INSTALL
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/INSTALL Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,39 @@
+Prerequisites:
+- a working installation of galaxy
+- R/Bioconductor
+- Ringo bioconductor library
+- rpy (version 1.0.x)
+- a working C++ compiler
+
+Installation:
+given a galaxy dir $GALAXYTOPDIR
+- extract the content of the archive into $GALAXYTOPDIR:
+
+ tar cvjf carpet.tar.bz2 -C $GALAXYTOPDIR
+
+- build the "comuni" executable:
+
+ cd $GALAXYTOPDIR/tools/CARPET
+ g++ com_uni.cpp -o comuni
+
+ (do NOT use optimizations if possible)
+
+- paste the content of add_to_tool_conf.xml within tool_conf.xml
+file (part of galaxy distribution), where needed and between the
+ tags
+
+- restart galaxy
+
+NOTES:
+- rpy2 is not implemented in carpet yet. You can download rpy (1.0.3) here:
+
+http://sourceforge.net/projects/rpy/files/rpy/1.0.3/rpy-1.0.3.tar.gz/download
+
+- You may install bioconductor's Ringo library just issuing the following within
+your R console:
+
+ source("http://bioconductor.org/biocLite.R")
+ biocLite("Ringo")
+
+- carpet has been deployed and tested on galaxy build 1349. There's no warranty it
+works on different builds (although it should).
\ No newline at end of file
diff -r 000000000000 -r cdd489d98766 carpet-src-1/add_to_tool_conf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/add_to_tool_conf.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._CARPET_userManual.zip
Binary file carpet-src-1/static/example_file/._CARPET_userManual.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._Expression_analysis_files.zip
Binary file carpet-src-1/static/example_file/._Expression_analysis_files.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._GFF_file_norm.txt.zip
Binary file carpet-src-1/static/example_file/._GFF_file_norm.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._Pair_file.txt.zip
Binary file carpet-src-1/static/example_file/._Pair_file.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._UCSC_hs_refGene_chr19.zip
Binary file carpet-src-1/static/example_file/._UCSC_hs_refGene_chr19.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._all_pair.txt.zip
Binary file carpet-src-1/static/example_file/._all_pair.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._log2ratio_file.txt.zip
Binary file carpet-src-1/static/example_file/._log2ratio_file.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/._raw_value.txt.zip
Binary file carpet-src-1/static/example_file/._raw_value.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/CARPET_userManual.zip
Binary file carpet-src-1/static/example_file/CARPET_userManual.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/Expression_analysis_files.zip
Binary file carpet-src-1/static/example_file/Expression_analysis_files.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/GFF_file_norm.txt.zip
Binary file carpet-src-1/static/example_file/GFF_file_norm.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/Pair_file.txt.zip
Binary file carpet-src-1/static/example_file/Pair_file.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/UCSC_hs_refGene_chr19.zip
Binary file carpet-src-1/static/example_file/UCSC_hs_refGene_chr19.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/all_pair.txt.zip
Binary file carpet-src-1/static/example_file/all_pair.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/log2ratio_file.txt.zip
Binary file carpet-src-1/static/example_file/log2ratio_file.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/example_file/raw_value.txt.zip
Binary file carpet-src-1/static/example_file/raw_value.txt.zip has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/CARPET_manual.pdf
Binary file carpet-src-1/static/images/CARPET/CARPET_manual.pdf has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/CARPET_manual_18.pdf
Binary file carpet-src-1/static/images/CARPET/CARPET_manual_18.pdf has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/Eno.png
Binary file carpet-src-1/static/images/CARPET/Eno.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/Tea.png
Binary file carpet-src-1/static/images/CARPET/Tea.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/background.png
Binary file carpet-src-1/static/images/CARPET/background.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/bec_output.png
Binary file carpet-src-1/static/images/CARPET/bec_output.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/centered.png
Binary file carpet-src-1/static/images/CARPET/centered.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/chi_squared.png
Binary file carpet-src-1/static/images/CARPET/chi_squared.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/chip.jpg
Binary file carpet-src-1/static/images/CARPET/chip.jpg has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/common_merg.png
Binary file carpet-src-1/static/images/CARPET/common_merg.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/common_princ.png
Binary file carpet-src-1/static/images/CARPET/common_princ.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/comparison.png
Binary file carpet-src-1/static/images/CARPET/comparison.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/correlation.png
Binary file carpet-src-1/static/images/CARPET/correlation.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/distribution.png
Binary file carpet-src-1/static/images/CARPET/distribution.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/expression.png
Binary file carpet-src-1/static/images/CARPET/expression.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/floowchart.png
Binary file carpet-src-1/static/images/CARPET/floowchart.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/hist_ann.png
Binary file carpet-src-1/static/images/CARPET/hist_ann.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/output_ann.png
Binary file carpet-src-1/static/images/CARPET/output_ann.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/output_no_sum.png
Binary file carpet-src-1/static/images/CARPET/output_no_sum.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/pvalue.png
Binary file carpet-src-1/static/images/CARPET/pvalue.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/pvalue_score.png
Binary file carpet-src-1/static/images/CARPET/pvalue_score.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/score.png
Binary file carpet-src-1/static/images/CARPET/score.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/sliding.png
Binary file carpet-src-1/static/images/CARPET/sliding.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/table_pv.png
Binary file carpet-src-1/static/images/CARPET/table_pv.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/table_score.png
Binary file carpet-src-1/static/images/CARPET/table_score.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/ucsc.jpg
Binary file carpet-src-1/static/images/CARPET/ucsc.jpg has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/ucsc2.jpg
Binary file carpet-src-1/static/images/CARPET/ucsc2.jpg has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/union.png
Binary file carpet-src-1/static/images/CARPET/union.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/static/images/CARPET/unique.png
Binary file carpet-src-1/static/images/CARPET/unique.png has changed
diff -r 000000000000 -r cdd489d98766 carpet-src-1/suite_config.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/suite_config.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,33 @@
+
+ This suite contains all tha CARPET tools created for Galaxy
+
+ looking into the chip
+
+
+ normalizing data
+
+
+ easy UCSC visualization of your raw-data
+
+
+ Finding Peaks in a GFF Nimblegen File
+
+
+ easy way to compare results
+
+
+ Gene Intervals Notator
+
+
+ of peaks distribution
+
+
+ Expression NOtator
+
+
+ Tiling Expression Analizer
+
+
+ Binding-Expression-Correlation
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/MapToExon_RefSeqMat.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/MapToExon_RefSeqMat.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,99 @@
+
+ Gene Intervals Notator
+ MapToExon_RefSeqMat_new.pl $input1 $input2 $promoter $3prime $priority $output
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+**What it does**
+
+GIN annotates peak queries (GFF files) with user defined transcript-annotation-tables (e.g. RefSeq, UCSC genes, Ensembl Genes etc).
+It calculates the relative position of the peack with respect to the associated features (e.g. promoter, exon, intron, intergenic)
+
+PLEASE, for more detailed information refer to the CARPET user Manual:
+click to download_ it.
+
+.. _download: /static/example_file/CARPET_userManual.zip
+
+--------
+
+.. class:: warningmark
+
+**Annotation Table**
+
+Annotation table is directly downloadable from **"Get Data"** section (**"UCSC Main table browser"** link).
+Pay attention to choose the right output format (**"all field from selected table"**) and check **"send output to Galaxy"**.
+
+It is possible to download many different annotation tables coming from different organisms and database such as RefSeq, UCSC gene, FlyBase, EST, etc etc...
+
+**All annotation tables must have headers.**
+
+Click here_ to download an Annotation Table file example.
+
+.. _here: /static/example_file/UCSC_hs_refGene_chr19.zip
+
+--------
+
+.. class:: warningmark
+
+**Custom annotation table**
+
+ .. class:: infomark
+
+
+ **About format**
+
+ Annotation table format must be the same downlodable from UCSC. In the specific case of this tool the following fields must be present:
+
+ 1. **chrom** - The name of the chromosome (e.g. chr1, chrY_random).
+ 2. **chromStart** - The starting position in the chromosome. (The first base in a chromosome is numbered 0.)
+ 3. **chromEnd** - The ending position in the chromosome, plus 1 (i.e., a half-open interval).
+ 4. **name** - The name of the BED line.
+ 5. **strand** - Defines the strand - either + or - .
+ 6. **blockCount** - The number of blocks (exons) in the BED line.
+ 7. **blockSizes** - A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount.
+ 8. **blockStarts** - A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount.
+
+
+The table **must** have headers
+
+
+--------
+
+**Options**
+
+- **Promoter definition:** extent of TSS (Trascription Starting Site) upstream sequence in base pairs.
+- **Annotaion priority:**
+ - if **promoter**: GIN tries to locate a peak in a promoter locus as first choice. If more than one promoter is found, the peak is associated to the closer transcriptional unit
+ - if **gene**: GIN tries to locate a peak in an exon as first choice.
+
+--------
+
+**How does it work?**
+
+**- Floowchart**
+
+.. image:: static/images/CARPET/floowchart.png
+
+
+**- Output**
+
+.. image:: static/images/CARPET/output_ann.png
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/MapToExon_RefSeqMat_new.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/MapToExon_RefSeqMat_new.pl Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,412 @@
+#!/usr/bin/perl
+
+# Copyright 2009 Matteo Cesaroni, Lucilla Luzi
+#
+# This program is free software; ; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser 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.
+
+
+$|=1;
+my $infile = $ARGV[0];
+my $infile2=$ARGV[1];
+my $definition_pro=$ARGV[2];
+my $definition_tre=$ARGV[3];
+my $priority=$ARGV[4];
+my $file_output=$ARGV[5];
+
+open (INFILE, "<$infile");
+open (INFILE2, "<$infile2");
+open (OUTFILE1, ">$file_output") or die "Cannot find file $file_output\n";
+
+$campi_t=0;
+$definition_out=$definition_pro-2000;
+
+while (defined (my $line_down = )) {
+ $line_down=~ s/\#//g;
+ chomp($line_down);
+ $campi_t++;
+ my @tmp_down=split(/\s+/, $line_down);
+ if($campi_t==1){
+ $z=0;
+ foreach $campo_t(@tmp_down){
+ if(($campo_t eq "name") || ($campo_t eq "qName") || ($campo_t eq "repClass")){
+ $zRef=$z;
+ }
+ if(($campo_t eq "txStart") || ($campo_t eq "tStart") || ($campo_t eq "chromStart")|| ($campo_t eq "genoStart")){
+ $ztxStart=$z;
+ }
+ if(($campo_t eq "txEnd") || ($campo_t eq "tEnd") || ($campo_t eq "chromEnd")|| ($campo_t eq "genoEnd")){
+ $ztxEnd=$z;
+ }
+ if($campo_t eq "strand"){
+ $zstrand=$z;
+ }
+ if(($campo_t eq "chrom") || ($campo_t eq "tName")|| ($campo_t eq "genoName")){
+ $zchrom=$z;
+ }
+ if(($campo_t eq "exonStarts") || ($campo_t eq "tStarts")){
+ $zexonstart=$z;
+ }
+ if($campo_t eq "exonEnds"){
+ $zexonend=$z;
+ }
+ if($campo_t eq "blockSizes"){
+ $zblocksize=$z;
+ }
+ if(($campo_t eq "name2") || ($campo_t eq "repFamily")){
+ $zname=$z;
+ }
+ if(($campo_t eq "exonCount")||($campo_t eq "blockCount")){
+ $zcount=$z;
+ }
+ $z++;
+ }
+ if(!$zname){
+ $zname=$zRef;
+ }
+ if(!$zexonstart){
+ $zexonstart=$ztxStart;
+ }
+ if(!$zexonend){
+ $zexonend=$ztxEnd;
+ }
+ if(($zRef eq "") || ($ztxStart eq "") || ($zstrand eq "") || ($zchrom eq "")){
+ print "Annotation file is not in the accepted format\n";
+ exit;
+ }else{print "promoter=$definition_pro, priority=$priority";}
+ next;
+ }
+ chomp $tmp_down[$zchrom];
+ $tab_ann{$tmp_down[$zchrom]}.="$line_down\n";
+}
+
+while (defined (my $line_down = )) {
+ my @tmp_down = split("\t", $line_down);
+ chomp $tmp_down[0];
+ $tab_probe{$tmp_down[0]}.=$line_down;
+}
+
+@chrom_probes= keys(%tab_probe);
+
+&chip;
+
+exit 0;
+
+###########
+#subrutine#
+###########
+
+sub chip
+{
+foreach $chromosoma (@chrom_probes){
+
+@file1=split("\n", $tab_probe{$chromosoma});
+
+foreach $line(@file1) {
+ chomp $line;
+ #chop $line;
+ if ($line=~/track/g){next;}
+ if ($line=~/#/g){next;}
+ if ($line=~/^\s+$/g){next;}
+ my @Line=split(/\t/, $line);
+ my $Chrom=$Line[0];
+ my $Start=$Line[3];
+ my $Stop=$Line[4];
+ #my $value=$Line[5];
+ my $ProbeName=$Line[5];
+ my $feature="ciccio";
+ my $check=0;
+ my $relative_dist=10000000;
+ $double_check=0;
+ @file2=split("\n", $tab_ann{$chromosoma});
+ foreach $linea(@file2) {
+ chomp $linea;
+ $linea=~ s/\#//g;
+ my @kEle=split("\t", $linea);
+ $ref=$kEle[$zRef];
+ $chrom=$kEle[$zchrom];
+ $strand=$kEle[$zstrand];
+ $transcriptStart=$kEle[$ztxStart];
+ $transcriptStop=$kEle[$ztxEnd];
+ if($zcount){
+ $exoncount=$kEle[$zcount];
+ }
+ else
+ {
+ $exoncount=1;
+ }
+ $geneName=$kEle[$zname];
+ $exonStartref=$kEle[$zexonstart];
+ my $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand";
+
+ my @exonStart=split(",", $exonStartref);
+
+ if (!$zblocksize){
+ $exonEndref=$kEle[$zexonend];
+ }
+ else {
+ @blockStop=split(",", $kEle[$zblocksize]);
+ $exonEndref="";
+ for ($jj=0; $jj<=$#exonStart; $jj++){
+ $end_block=$exonStart[$jj]+$blockStop[$jj];
+ $exonEndref.="$end_block,";
+
+ }
+ }
+
+ my @exonStop=split(",", $exonEndref);
+
+ #print "$ref / $chrom / $strand / $transcriptStart/$transcriptStop/$exoncount/$geneName [$#exonStop]\n";
+ #print "pippo $exonStart[0] - $exonStop[0],$exonStart[1] - $exonStop[1],$exonStart[2] - $exonStop[2] \n";
+
+
+ if ($Chrom eq $chrom) {
+ #print "cazzo";
+ if ($strand eq "+"){
+ $promotore=$transcriptStart+$definition_pro;
+ $distanzaTSS=int((($Start+$Stop)/2)-$transcriptStart);
+ $trepr=$transcriptStop+$definition_tre;
+ $rel_start=$promotore;
+ $rel_stop=$trepr;
+ }
+ if ($strand eq "-"){
+ $promotore=$transcriptStop-$definition_pro;
+ $distanzaTSS=int($transcriptStop-(($Start+$Stop)/2));
+ $trepr=$transcriptStart-$definition_tre;
+ $rel_start=$trepr;
+ $rel_stop=$promotore;
+ }
+ #print OUTFILE1 "$ref\t$distanzaTSS\n";
+
+ #if(($Start<=$transcriptStart && $Stop>$transcriptStart) || ($Start>=$promotore && $Stop<=$transcriptStart) || ($Start>=$transcriptStop && $Stop<=$promotore) || ($Start<=$promotore && $Stop>$promotore) || ($Start<$transcriptStop && $Stop>=$transcriptStop) || ($Start>=$transcriptStart && $Stop<=$transcriptStop) ){
+ #print "sono entrato con start $Start stop $Stop e $transcriptStart e $transcriptStop\n";
+
+ if($Start<=$rel_stop && $rel_start<=$Stop){
+
+ for(my $i=0;$i<=$#exonStart;$i++) {
+
+ if ($strand eq "+"){
+ $exoncount1=$i+1;
+ $exoncount2=$exoncount1;
+ $introncount=$exoncount1;
+ if($i==$#exonStart) {
+ $exoncount2="last";
+ $introncount="last";
+ }
+ if($i==$#exonStart-1) {
+ $introncount="last";
+ }
+ }
+ if ($strand eq "-"){
+ $exoncount1=($#exonStart+1)-$i;
+ $exoncount2=$exoncount1;
+ $introncount=$exoncount1-1;
+ #if(($i==0) && ($#exonStart != 0)) {$exoncount2="last";}
+ if($i==0) {
+ $exoncount2="last";
+ $introncount="last";
+ }
+ }
+ #print "esone start $exonStart[$i] e $exonStop[$i] e start $Start\n";
+
+ #print OUTFILE1 "$ref\t$exonStart[$i]\t$exonStop[$i]\t$Start\t$Stop\t$i\t$#exonStart\t$priority\n";
+
+
+
+ #if($priority eq "prom" && $check==1){
+ # last;
+ #}
+ #if($priority eq "gene" && $check==2){
+ # next;
+ #}
+
+
+ if(($Start<=$exonStart[$i]) && ($Stop>$exonStart[$i])){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tintronexon $exoncount2\t$distanzaTSS";
+ if($priority eq "prom"){
+ $check=2;
+ }
+ else{
+ $check=1;
+ #last;
+ }
+ }
+ if(($Start>=$exonStart[$i]) && ($Stop<=$exonStop[$i])){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\texon $exoncount2\t$distanzaTSS";
+ if($priority eq "prom"){
+ $check=2;
+ }
+ else{
+ $check=1;
+ #last;
+ }
+ }
+ if(($Start<$exonStop[$i]) && ($Stop>$exonStop[$i])){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\texonintron $introncount\t$distanzaTSS";
+ if($priority eq "prom"){
+ $check=2;
+ }
+ else{
+ $check=1;
+ #last;
+ }
+ }
+ if($priority eq "prom"){
+ if(($Start>=$exonStop[$i]) && ($Stop<=$exonStart[$i+1]) && ($check==0)){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tintron $introncount\t$distanzaTSS";
+ #print "intron\n";
+ $check=2;
+ }
+ }
+ else{
+ if(($Start>=$exonStop[$i]) && ($Stop<=$exonStart[$i+1])){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tintron $introncount\t$distanzaTSS";
+ #print "intron\n";
+ $check=2;
+ }
+ }
+
+
+
+ if (($strand eq "+") && ($Start>=$transcriptStop)) {
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\t3_prime\t$distanzaTSS";
+ $distanzaTSS=int($transcriptStop-(($Start+$Stop)/2));
+ if($priority eq "prom"){
+ $check=2;
+ #last;
+ }
+ else{$check=1;}
+ }
+ if (($strand eq "-") && ($Stop<=$transcriptStart)) {
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\t3_prime\t$distanzaTSS";
+ $distanzaTSS=int((($Start+$Stop)/2)-$transcriptStart);
+ if($priority eq "prom"){
+ $check=2;
+ #last;
+ }
+ else{$check=1;}
+ }
+
+
+
+
+ if (($strand eq "+") && (($Start<=$promotore && $Stop>$promotore) || ($Start>$promotore && $Stop<=$transcriptStart))) {
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tpromoter\t$distanzaTSS";
+ if($priority eq "prom"){
+ $check=1;
+ #last;
+ }
+ else{$check=2;}
+ }
+ if (($strand eq "-") && (($Start<=$promotore && $Stop>=$promotore) || ($Start>=$transcriptStop && $Stop<$promotore))) {
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tpromoter\t$distanzaTSS";
+ if($priority eq "prom"){
+ $check=1;
+ #last;
+ }
+ else{$check=2;}
+ }
+
+ if(($Start<=$exonStart[$i]) && ($i==0) && ($strand eq "+") && ($Stop>=$exonStart[$i])){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tprom_exon $exoncount2\t$distanzaTSS";
+ #print "prom-exon e $exoncount1\n";
+ if($priority eq "prom"){
+ $check=1;
+ #last;
+ }
+ else{$check=2;}
+ }
+ if(($Start<=$exonStop[$i]) && ($i==$#exonStart) && ($strand eq "-") && ($Stop>=$exonStop[$i])){
+ $feature="$ref\t$geneName\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tprom_exon $exoncount2\t$distanzaTSS";
+ if($priority eq "prom"){
+ $check=1;
+ #last;
+ }
+ else{$check=2;}
+ }
+
+ }
+ #if ($check==1){
+ # print "$chrom\t$Start\t$Stop\t$geneName\t$exoncount\t$ref\t$strand\t$feature\n";
+ #}
+ }else{next;}
+ #exit;
+ }else{next;}
+
+ #print OUTFILE1 "$ref\t$feature\n";
+ #print "$geneName\t$transcriptStart\t$Chrom\t$Start\t$Stop\t$distanzaTSS\t$feature\n";
+
+ if (($priority eq "gene") && ($relative_dist>abs($distanzaTSS))){
+ $relative_dist=abs($distanzaTSS);
+ $stampa="$Chrom\t$Start\t$Stop\t$ProbeName\t$feature\n";
+ $double_check=1;
+ }
+ if (($check==1) && ($priority eq "prom") && ($relative_dist>abs($distanzaTSS))){
+ $relative_dist=abs($distanzaTSS);
+ $double_check=1;
+ $stampa="$Chrom\t$Start\t$Stop\t$ProbeName\t$feature\n";
+ }
+ }
+
+
+
+ if($double_check==1){
+ print OUTFILE1 "$stampa";
+ next;
+ }
+ if (($check==2) && ($priority eq "prom")){
+ print OUTFILE1 "$Chrom\t$Start\t$Stop\t$ProbeName\t$feature\n";
+ next;
+ }
+ if($check==0){
+ print OUTFILE1 "$Chrom\t$Start\t$Stop\t$ProbeName\tintergenic\tintergenic\t$Start\t$Stop\t+\t0\tOUT\t$definition_out\n";
+ next;
+ }
+}
+}
+close INFILE;
+close INFILE2;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/PeakPeaker.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/PeakPeaker.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,139 @@
+
+ Finding Peaks in a GFF Nimblegen File
+ PeakPeaker2.pl --in $input --out $output --t $type --dist_peaks $dist_peaks --col3 $col3 --log $log --perc $perc --num $num --dist $dist --w $window --f_pv $output2
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+**What it does**
+
+This tool utilizes NimbleGen ratio files in gff format as INPUT FILE and provides a table of the computed peaks in the same gff format.
+
+--------
+
+**Parameters:**
+
+- **Analysis type:**
+ - **p-value** analysis performs peaks determination based on p-value inference
+ - **score** analysis performs peaks determination based on a scoring system
+- **Percentile value:** it is used to calculate the threshold rate based on dataset distribution to filter out background
+- **-log p-value cutoff:** (required only for p-value based analysis) cutoff integer to be used to identify a significant peak
+- **minimal # of probes:** minimal number of consecutive probes used to define a peak
+- **max distance 2 probes:** greatest nucleotide distance (bp) between two probes that allow to consider two probes as adjacent
+- **min distance 2 peaks:** minimum nucleotide distance (bp) required to consider two peaks as separate entities
+- **window length:** length in bp of the window used for statistical analysis
+
+--------
+
+
+**INPUT FILE**
+
+Nimblegen gives you back a GFF file with the coordinates of each probe and the normalized signal value --> log2(Cy5/Cy3).
+
+Click here_ to download a GFF file example.
+
+.. _here: /static/example_file/GFF_file_norm.txt.zip
+
+Example of Nimblegen GFF format::
+
+ chr19 Nimblegen tiling_array 100000 1000051 -1.2 + . probe_name
+ chr19 Nimblegen tiling_array 100100 1000151 2.9 + . probe_name
+
+.. class:: warningmark
+
+The sixth column **must** contain the normalized log2(cy5/cy3) that Nimblegen gives you back after the experiment
+
+
+---------
+
+.. class:: infomark
+
+**How does it work?**
+
+**Two assumptions:**
+
+
+- data are enriched for signal in the positive direction ("one-tailed")
+- a peak (or enriched region) is represented by multiple probes that are genomically located close to each other
+
+
+**Statistical approach: sliding window**
+
+
+A window centered at each probe of the array moves probe by probe. In each window Chi squared is calculated
+
+
+.. image:: static/images/CARPET/chi_squared.png
+
+
+by building a contingency table for each probe, and a p-value is assigned
+
+
+.. image:: static/images/CARPET/centered.png
+
+
+**"-log2(p-value)"** is associated to each probe. This value takes in account the neighbouring probes effect.
+This approach dramatically decreases the background signal.
+
+
+.. image:: static/images/CARPET/background.png
+
+
+New values are considered to defined an enriched locus
+
+
+.. image:: static/images/CARPET/pvalue.png
+
+
+Moreover a score is calculated taking into account the length and the raw signal of the peak
+
+
+.. image:: static/images/CARPET/pvalue_score.png
+
+
+Output is a gff file
+
+
+.. image:: static/images/CARPET/table_pv.png
+
+
+**NON Statistical approach: score**
+
+
+Only the raw signal of each probe is considered. Only the regions with a number of consecutive probes above the defined threshold are selected
+
+
+.. image:: static/images/CARPET/score.png
+
+
+Output is a GFF file
+
+
+.. image:: static/images/CARPET/table_score.png
+
+
+and a GFF file with the p-values associate to each probe
+
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/PeakPeaker2.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/PeakPeaker2.pl Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,432 @@
+#! /usr/bin/perl
+
+# Copyright 2009 Matteo Cesaroni, Lucilla Luzi
+#
+# This program is free software; ; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser 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.
+
+
+use Getopt::Long;
+
+GetOptions (
+ "help" => \$OPT{help},
+ "in=s" => \$OPT{fname},
+ "perc=s" => \$OPT{value},
+ "fc=s" => \$OPT{fc_value},
+ "log=s" => \$OPT{valore_log},
+ "t=s" => \$OPT{type_peak},
+ "num=s" => \$OPT{num_probe},
+ "dist=s" => \$OPT{dist_max},
+ "dist_peaks=s" => \$OPT{dist_max_peaks},
+ "w=s"=> \$OPT{s_windows},
+ "col3=s" => \$OPT{col3},
+ "f_pv=s" => \$OPT{file_pv},
+ "out=s"=> \$OPT{out}
+
+)|| printusage();
+
+# opzioni da linea di comando
+my $value=$OPT{value};
+my $fc_value=$OPT{fc_value};
+my $valore_log=$OPT{valore_log};
+my $type_peak=$OPT{type_peak};
+my $num_probe=$OPT{num_probe};
+my $dist_max=$OPT{dist_max};
+my $dist_max_peaks=$OPT{dist_max_peaks};
+my $fname=$OPT{fname};
+my $help=$OPT{help};
+my $s_windows=$OPT{s_windows};
+my $col3=$OPT{col3};
+my $outfile=$OPT{out};
+my $outfile_pv=$OPT{file_pv},
+
+# "usage" se c'e' un help
+$help and printusage();
+
+# "usage" se non ci sono opzioni
+if (!$s_windows || !$fname || (!$value && !$fc_value) || !$type_peak || !$num_probe || !$dist_max || (($type_peak eq "p") && !$valore_log)){
+ &printusage()
+};
+
+
+qx {sort -k 1,1 -k 4,4n $fname >$fname.sortato};
+
+
+open(FILE, "<$fname.sortato") or die "Cannot find file $fname.sortato\n";
+open(pvalue, ">$outfile_pv") or die "Cannot open file $outfile_pv: $!\n";
+#open(buonitutti, "> buoni_$fname") or die "Cannot find file $fname: $!\n";
+#loop th rought line-by-line until the end of the file and then push each line into an empty array, called @array#
+print pvalue "#p-value track ($value) \n";
+
+
+@array= ();
+$conto_tutti_sopra=0;
+$conto_tutti=0;
+while ($line = ){
+ chomp ($line);
+ if ($line=~/track/g){next;}
+ if ($line=~/#/g){next;}
+ if ($line=~/^\s+$/g){next;}
+ push (@array,$line);
+ @value_perc=split("\t",$line);
+ push (@percentile,$value_perc[5]);
+ if ($value_perc[5]>=$fc_value){
+ $conto_tutti_sopra++;
+ }
+ elsif ($value_perc[5]<$fc_value){
+ $conto_tutti++;
+ }
+}
+
+close (FILE);
+
+if (!$fc_value){
+@perc_ordine=sort(@percentile);
+$position=(($value*($#perc_ordine+1))-1);
+$valore_percentile=$perc_ordine[$position];
+ #print "il percentile è $valore_percentile\n";
+ #print "il max è $perc_ordine[$#perc_ordine]\n";
+ #print "il min è $perc_ordine[1]\n";
+$probabilita=1-$value;
+}
+else {
+ $valore_percentile=$fc_value;
+ $tuttitutti=($conto_tutti+$conto_tutti_sopra);
+ #print"il numero totaledi probe è $tuttitutti\n";
+ #print"il numero totale di probe sopra è $conto_tutti_sopra\n";
+ $probabilita=$conto_tutti_sopra/($conto_tutti+$conto_tutti_sopra);
+ #print "la proba= $probabilita\n";
+ }
+
+#print buonitutti"il percentile e $valore_percentile\n";
+
+
+
+($one_ref,$two_ref)=&probe_cutoff(@array);
+
+if ($type_peak eq "p"){
+ @forse_niente=&peak(@$one_ref);
+ }
+elsif ($type_peak eq "s"){
+ @forse_niente=&peak(@$two_ref);
+ }
+
+&double_peak(@forse_niente);
+
+#
+# End process
+#
+close OUTFILE;
+unlink "$fname.sortato";
+exit 0;
+
+################################################################################################
+######################## SUBROUTINE ###############################
+################################################################################################
+
+sub probe_cutoff
+{
+
+$c=-6;
+
+foreach $linea(@array){
+ @subarray1 = split("\t",$linea);
+ $inizio=(((($subarray1[4]-$subarray1[3])/2)+$subarray1[3])-($s_windows/2)); #per modificare la windows cambia il 500 e il 1000
+ $fine=$inizio+$s_windows; #windows 500 -->250 e 500 windows 1000 --> 500 e 1000
+ $counter=0;
+ $counter_value=0;
+
+ if($subarray1[5]>=$valore_percentile){
+ push (@array_probe,[@subarray1]);
+ print buonitutti "$linea\n";
+ }
+
+ for($i=$c;$i<=$#array;$i++) {
+ if ($i<0){
+ next;
+ }
+ @subarray = split("\t",$array[$i]);
+ if (($subarray[3]>=$inizio)&&($subarray[3]<$fine)&&("$subarray[0]" eq "$subarray1[0]")){
+ $counter++;
+ if ($subarray[5]>= $valore_percentile){
+ $counter_value++;
+ }
+ }
+ if (($subarray[3]>$fine)||("$subarray[0]" ne "$subarray1[0]")){
+ $cazzo=$subarray[3];
+ last;
+ }
+
+ }
+$c++;
+ if ($counter !=0){
+ $chi_sq = (((($counter_value - ($probabilita*$counter))**2)/($probabilita*$counter))+(((($counter-$counter_value)-((1-$probabilita)*$counter))**2)/((1-$probabilita)*$counter)));
+ }
+ else{
+ $chi_sq = NA;
+ }
+
+use Statistics::Distributions;
+$chisprob=Statistics::Distributions::chisqrprob (1,$chi_sq);
+if ($chisprob == 0){
+ $log_10=100;
+}
+else {
+ $log_10 = -log($chisprob)/log(10);
+}
+
+print pvalue "$subarray1[0]\t$subarray1[1]\tpv_$subarray1[2]\t$subarray1[3]\t$subarray1[4]\t$log_10\t$subarray1[6]\t$subarray1[7]\t$subarray1[5]\n";
+
+ if ($log_10>=$valore_log){
+ #print"$subarray1[3],$inizio,$fine,$counter,$counter_value,$chi_sq,$chisprob,$log_10\n";
+ @proviamo=($subarray1[0],$subarray1[1],$subarray1[2],$inizio,$fine,$log_10,$subarray1[6],$subarray1[7],$subarray1[5]);
+ push (@matrix_pvalue,[@proviamo]);
+
+ }
+}
+@result_table=@matrix_pvalue;
+@result_table2=@array_probe;
+return(\@result_table,\@result_table2);
+
+}
+
+
+
+
+
+################################################################################################
+
+
+
+sub peak
+{
+@matrix_value=@_;
+
+$stop=$#matrix_value;
+
+for ($cio=0; $cio<=$stop;$cio++) {
+ @log_ratio=();
+ @chilosa=();
+ $inizio=$matrix_value[$cio][3];
+ $somma=0;
+ $media=0;
+ $sommachilo=0;
+ $mediachilo=0;
+ $diviso=0;
+ push(@log_ratio,$matrix_value[$cio][5]);
+ if ($matrix_value[$cio][8]>=$valore_percentile){
+ push(@chilosa,$matrix_value[$cio][8]);
+ }
+ for ($j=0; $j<=$stop;$j++){
+ $distanza=($matrix_value[$cio+1][3]-$matrix_value[$cio][4]);
+ if (($distanza > $dist_max) || ($cio==$stop)||(!("$matrix_value[$cio+1][0]" eq "$matrix_value[$cio][0]"))){
+ $j=$stop;
+ }
+ elsif (($distanza <= $dist_max)&&("$matrix_value[$cio+1][0]" eq "$matrix_value[$cio][0]")){
+ $cio++;
+ push(@log_ratio,$matrix_value[$cio][5]);
+ $fine=$matrix_value[$cio][4];
+ $inizio3=$inizio;
+ $j++;
+ if ($matrix_value[$cio][8]>=$valore_percentile){
+ push(@chilosa,$matrix_value[$cio][8]);
+ }
+ }
+
+
+ }
+ $numeroprobes=($#chilosa+1);
+ if ((($#log_ratio+1)>=$num_probe) && (($type_peak eq "s") ||(($#chilosa+1)>=$num_probe))){
+ foreach $n (@log_ratio) {
+ $somma+=$n;
+ }
+ if($type_peak eq "s"){
+ @chilosa=@log_ratio;
+ }
+ foreach $nchilo (@chilosa) {
+ $sommachilo+=$nchilo;
+ }
+ $diviso=$#log_ratio+1;
+ $media = $somma/(@log_ratio);
+ $mediachilo=$sommachilo/(@chilosa);
+ #$somma_media_chilo=((sqrt($#chilosa+1))+$mediachilo);
+ #$moltipli=(($#log_ratio+1)*$media);
+ #$somma_media=((sqrt($#log_ratio+1))+$media);
+ if ($type_peak eq "p"){
+ $inizio3=int($inizio3+(($s_windows/2)-25));
+ $fine=int($fine-(($s_windows/2)-25));
+ }
+ @proviamo_double=($matrix_value[$cio][0],$matrix_value[$cio][1],$col3,$inizio3,$fine,$media,$matrix_value[$cio][6],$matrix_value[$cio][7],$mediachilo,$diviso);
+ push (@matrix_for_double,[@proviamo_double]);
+
+ }
+}
+
+@result_table=@matrix_for_double;
+return(@result_table);
+}
+
+
+################################################################################################
+
+
+
+sub double_peak
+{
+@matrix_value=@_;
+
+$stop=$#matrix_value;
+$i=0;
+$j=0;
+#print $stop;
+
+#
+# Print output file
+#
+if ($outfile){
+ open (OUTFILE, ">$outfile");
+}
+
+#
+# print File Header
+#
+my $header=< $dist_max_peaks) || ($i==$stop)||(!("$matrix_value[$i+1][0]" eq "$matrix_value[$i][0]"))){
+ $j=$stop;
+ $fine=$matrix_value[$i][4];
+ }
+ elsif (($distanza <= $dist_max_peaks)&&("$matrix_value[$i+1][0]" eq "$matrix_value[$i][0]")){
+ $i++;
+ push(@log_ratio,$matrix_value[$i][5]);
+ push(@log_ratio2,$matrix_value[$i][8]);
+ push(@diviso2,$matrix_value[$i][9]);
+ $fine=$matrix_value[$i][4];
+ $j++;
+ }
+
+ # }
+ }
+ foreach $n (@log_ratio) {
+ $somma+=$n;
+ }
+ foreach $n1 (@log_ratio2) {
+ $somma2+=$n1;
+ }
+ foreach $n2 (@diviso2) {
+ $diviso2+=$n2;
+ }
+ $media = $somma/(@log_ratio);
+ $media2 = $somma2/(@log_ratio2);
+ $somma_media=(sqrt($diviso2)+$media);
+ $somma_score=(sqrt($diviso2)+$media2);
+ $somma_media = sprintf "%.2f", $somma_media;
+ $somma_score = sprintf "%.2f", $somma_score;
+ #$somma_score = $somma_score.$i
+ #$somma_media_chilo=((sqrt($#chilosa+1))+$mediachilo);
+ if ($outfile){
+ print OUTFILE "$matrix_value[$i][0]\t$matrix_value[$i][1]\t$matrix_value[$i][2]\t$inizio\t$fine\t$somma_media\t$matrix_value[$i][6]\t$matrix_value[$i][7]\t$somma_score$i\n";
+ }else{
+ print "$matrix_value[$i][0]\t$matrix_value[$i][1]\t$matrix_value[$i][2]\t$inizio\t$fine\t$somma_media\t$matrix_value[$i][6]\t$matrix_value[$i][7]\t$somma_score$i\n";
+ }
+
+
+}
+}
+
+####################################################################################################################################
+
+sub printusage {
+
+ print< 0:
+ print "..skipped %d invalid lines starting with line #%d. Value '%s' is not numeric." % ( skipped_lines, first_invalid_line, invalid_value )
+
+ r.quit( save="no" )
+
+if __name__ == "__main__":
+ main()
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/Raw_data.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/Raw_data.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,58 @@
+
+ looking into the chip
+ Raw_data.py $input $output $numerical_column_PM $numerical_column_x $numerical_column_y $title
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**What it does**
+
+This tool creates the image of the array to make sure that no artifacts are present on the surface.
+
+PLEASE, for more detailed information refer to the CARPET user Manual:
+click to download_ it.
+
+.. _download: /static/example_file/CARPET_userManual.zip
+
+-----
+
+.. class:: warningmark
+
+This tool requires at least three numerical column **"X position"**, **"Y position"** (the position coordinates on the chip of each probe) and **"PM value"** (the raw signal of each probe).
+
+-----
+
+**Example**
+
+- On **Get Data** section it is possible to upload your files clicking on **"Upload File from your computer"**.
+
+ Click here_ to download a pair_file example.
+
+.. _here: /static/example_file/Pair_file.txt.zip
+
+- Input dataset pair_file from NimbleGen contained all these informations (eleven columns: c1, c2, c3, c4, c5... c11)::
+
+ c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11
+ IMAGE_ID GENE_EXPR_OPTION SEQ_ID PROBE_ID POSITION X Y MATCH_INDEX SEQ_URL PM MM
+ 1251702_635 FORWARD CHR19 CHR1900P000011001 11001 565 381 64160375 ____ 5459.89 0.00
+ 1251702_635 FORWARD CHR19 CHR1900P000011050 11050 610 656 64160376 ____ 865.75 0.00
+
+
+- Chose column **c10** for "PM value", **c6** for "X position" and **c7** for "Y position".
+
+
+
+.. image:: static/images/CARPET/chip.jpg
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/TSS_distance.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/TSS_distance.py Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+
+# Copyright 2009 Matteo Cesaroni, Lucilla Luzi
+#
+# This program is free software; ; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser 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.
+
+
+import sys
+from rpy import *
+
+
+def stop_err(msg):
+ sys.stderr.write(msg)
+ sys.exit()
+
+def main():
+
+ # Handle input params
+ in_fname = sys.argv[1]
+ out_fname = sys.argv[2]
+ try:
+ column = int( sys.argv[3] ) - 1
+ except:
+ stop_err( "..Column not specified, your query does not contain a column of numerical data." )
+ title = sys.argv[4]
+ xlab = sys.argv[5]
+ breaks = int( sys.argv[6] )
+ if breaks == 0: breaks = "Sturges"
+ if sys.argv[7] == "true": density = True
+ else: density = False
+
+
+
+ matrix = []
+ skipped_lines = 0
+ first_invalid_line = 0
+ invalid_value = ''
+
+ for i, line in enumerate( file( in_fname ) ):
+ valid = True
+ line = line.rstrip('\r\n')
+ # Skip comments
+ if line and not line.startswith( '#' ):
+ # Extract values and convert to floats
+ row = []
+ try:
+ fields = line.split( "\t" )
+ val = fields[column]
+ if val.lower() == "na":
+ row.append( float( "nan" ) )
+ if float(val) > float(xlab):
+ val = (float(xlab)+2000)
+
+ row.append( float( val ) )
+ except:
+ valid = False
+ skipped_lines += 1
+ if not first_invalid_line:
+ first_invalid_line = i+1
+ else:
+ try:
+ row.append( float( val ) )
+ except ValueError:
+ valid = False
+ skipped_lines += 1
+ if not first_invalid_line:
+ first_invalid_line = i+1
+ invalid_value = fields[column]
+ else:
+ valid = False
+ skipped_lines += 1
+ if not first_invalid_line:
+ first_invalid_line = i+1
+
+ if valid:
+ matrix.append( row )
+
+ if skipped_lines < i:
+ print "..on columnn %s" %sys.argv[3]
+ try:
+ a = array( matrix )
+ r.pdf( out_fname, 8, 8 )
+ r.hist( a, probability=True, main=title, xlab="TSS distance", breaks=breaks )
+ if density:
+ r.lines( r.density( a ) )
+ r.dev_off()
+ except exc:
+ stop_err("Building histogram resulted in error: %s." %str( exc ))
+ else:
+ print "..all values in column %s are non-numeric." %sys.argv[3]
+
+ if skipped_lines > 0:
+ print "..skipped %d invalid lines starting with line #%d. Value '%s' is not numeric." % ( skipped_lines, first_invalid_line, invalid_value )
+
+ r.quit( save="no" )
+
+if __name__ == "__main__":
+ main()
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/TSS_distance.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/TSS_distance.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,61 @@
+
+ of peaks distribution
+ TSS_distance.py $input $out_file1 $numerical_column "$title" $window $breaks $density
+
+
+
+
+
+
+
+
+
+
+
+
+
+.. class:: infomark
+
+**What it does**
+
+This tool generates a distribution of peaks with respect to their distance from TSS.
+
+PLEASE, for more detailed information refer to the CARPET user Manual:
+click to download_ it.
+
+.. _download: /static/example_file/CARPET_userManual.zip
+
+-----
+
+.. class:: warningmark
+
+This tool requires at least 1 numerical column **"distance from TSS"**.
+
+-----
+
+**Syntax**
+
+- All invalid, blank and comment lines in the query are skipped. The number of skipped lines is displayed in the resulting history item.
+- **Numerical column for x axis** - only numerical columns are possible.
+- **Number of breaks(bars)** - breakpoints between histogram cells. Value of '0' will determine breaks automatically.
+- **Plot title** - the histogram title.
+- **Label for x axis** - the label of the x axis for the histogram.
+- **Zoom visualization** - Limit of the X axis. All the peaks falling beyond this limit are plotted in the last histogram cell.
+- **Include smoothed density** - if checked, the resulting graph will join the given corresponding points with line segments.
+
+-----
+
+**Example**
+
+- Input dataset ann_file from GIN (twelve columns: c1, c2, c3, c4, c5... c12):
+
+.. image:: static/images/CARPET/output_ann.png
+
+
+- Chose column **c12** ("Distance TSS").
+
+.. image:: static/images/CARPET/hist_ann.png
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/annotation_expr.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/annotation_expr.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,74 @@
+
+ Expression NOtator
+ annotation_expr_intron.pl $input1 $input2 $output
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+**What it does**
+
+ENO assigns each exon of a transcript the relative matching probes of the array. If a probe matches with more than one transcript, it is associated to every transcript.
+
+PLEASE, for more detailed information refer to the CARPET user Manual:
+click to download_ it.
+
+.. _download: /static/example_file/CARPET_userManual.zip
+
+--------
+
+.. class:: warningmark
+
+**Annotation Table**
+
+Annotation table was directly downloadable from **"Get Data"** section (**"UCSC Main table browser"** link).
+Pay attention to choose the right output format (**"all field from selected table"**) and check **"send output to Galaxy"**.
+
+It is possible to download many different annotation tables coming from different organisms and database such as RefSeq, UCSC gene, FlyBase, EST, etc etc...
+
+**All annotation tables must have headers.**
+
+
+--------
+
+.. class:: warningmark
+
+**Custom annotation table**
+
+ .. class:: infomark
+
+
+ **About format**
+
+ Annotation table format must be the same downlodable from UCSC. In the specific case of this tool the following fields must be present:
+
+ 1. **chrom** - The name of the chromosome (e.g. chr1, chrY_random).
+ 2. **chromStart** - The starting position in the chromosome. (The first base in a chromosome is numbered 0.)
+ 3. **chromEnd** - The ending position in the chromosome, plus 1 (i.e., a half-open interval).
+ 4. **name** - The name of the BED line.
+ 5. **strand** - Defines the strand - either + or - .
+ 6. **blockCount** - The number of blocks (exons) in the BED line.
+ 7. **blockSizes** - A comma-separated list of the block sizes. The number of items in this list should correspond to blockCount.
+ 8. **blockStarts** - A comma-separated list of block starts. All of the blockStart positions should be calculated relative to chromStart. The number of items in this list should correspond to blockCount.
+
+
+The table **must** have headers
+
+
+---------
+
+.. class:: infomark
+
+**How does it work?**
+
+.. image:: static/images/CARPET/Eno.png
+
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/annotation_expr_intron.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/annotation_expr_intron.pl Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,232 @@
+#!/usr/bin/perl
+
+# Copyright 2009 Matteo Cesaroni, Lucilla Luzi
+#
+
+# This program is free software; ; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser 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.
+
+
+
+$|=1;
+my $infile = $ARGV[0];
+my $infile2=$ARGV[1];
+my $file_output=$ARGV[2];
+
+open (INFILE, "<$infile");
+open (INFILE2, "<$infile2");
+open (OUTFILE1, ">$file_output") or die "Cannot find file $file_output\n";
+
+$campi_t=0;
+while (defined (my $line_down = )) {
+ $line_down=~ s/\#//g;
+ chomp($line_down);
+ $campi_t++;
+ my @tmp_down=split(/\s+/, $line_down);
+ if($campi_t==1){
+ $z=0;
+ foreach $campo_t(@tmp_down){
+ if(($campo_t eq "name") || ($campo_t eq "qName")){
+ $zRef=$z;
+ }
+ if(($campo_t eq "txStart") || ($campo_t eq "tStart") || ($campo_t eq "chromStart")){
+ $ztxStart=$z;
+ }
+ if(($campo_t eq "txEnd") || ($campo_t eq "tEnd") || ($campo_t eq "chromEnd")){
+ $ztxEnd=$z;
+ }
+ if($campo_t eq "strand"){
+ $zstrand=$z;
+ }
+ if(($campo_t eq "chrom") || ($campo_t eq "tName")){
+ $zchrom=$z;
+ }
+ if(($campo_t eq "exonStarts") || ($campo_t eq "tStarts")){
+ $zexonstart=$z;
+ }
+ if($campo_t eq "exonEnds"){
+ $zexonend=$z;
+ }
+ if($campo_t eq "blockSizes"){
+ $zblocksize=$z;
+ }
+ if($campo_t eq "name2"){
+ $zname=$z;
+ }
+ if(($campo_t eq "exonCount")||($campo_t eq "blockCount")){
+ $zcount=$z;
+ }
+ $z++;
+ }
+ if(!$zname){
+ $zname=$zRef;
+ }
+ if(!$zexonstart){
+ $zexonstart=$ztxStart;
+ }
+ if(!$zexonend){
+ $zexonend=$ztxEnd;
+ }
+ if(($zRef eq "") || ($ztxStart eq "") || ($zstrand eq "") || ($zchrom eq "")){
+ print "Annotation file is not in the accepted format\n";
+ exit;
+ }else{print "Expression chip annotation";}
+ next;
+ }
+ chomp $tmp_down[$zchrom];
+ $tab_ann{$tmp_down[$zchrom]}.="$line_down\n";
+}
+
+while (defined (my $line_down = )) {
+ my @tmp_down = split("\t", $line_down);
+ chomp $tmp_down[0];
+ $tab_probe{$tmp_down[0]}.=$line_down;
+}
+
+@chrom_probes= keys(%tab_probe);
+
+&expression;
+
+
+exit 0;
+
+
+###########
+#subrutine#
+###########
+
+sub expression
+{
+foreach $chromosoma (@chrom_probes){
+ %gene_cen="";
+ @file2=split("\n", $tab_ann{$chromosoma});
+ foreach $linea(@file2) {
+ chomp $linea;
+ $linea=~ s/#//g;
+ my @kEle=split(/\s+/, $linea);
+ $ref=$kEle[$zRef];
+ $chrom=$kEle[$zchrom];
+ $strand=$kEle[$zstrand];
+ $transcriptStart=$kEle[$ztxStart];
+ $transcriptStop=$kEle[$ztxEnd];
+ if($zcount){
+ $exoncount=$kEle[$zcount];
+ }
+ else
+ {
+ $exoncount=1;
+ }
+ $geneName=$kEle[$zname];
+ $exonStartref=$kEle[$zexonstart];
+
+ my @exonStart=split(",", $exonStartref);
+
+ if (!$zblocksize){
+ $exonEndref=$kEle[$zexonend];
+ }
+ else {
+ @blockStop=split(",", $kEle[$zblocksize]);
+ $exonEndref="";
+ for ($jj=0; $jj<=$#exonStart; $jj++){
+ $end_block=$exonStart[$jj]+$blockStop[$jj];
+ $exonEndref.="$end_block,";
+
+ }
+ }
+
+ my @exonStop=split(",", $exonEndref);
+
+ #print @exonStart;
+
+ @file1=split("\n",$tab_probe{$chromosoma});
+
+ foreach $line(@file1) {
+ chomp $line;
+ #chop $line;
+ if ($line=~/track/g){next;}
+ if ($line=~/#/g){next;}
+ if ($line=~/^\s+$/g){next;}
+ my @Line=split(/\t/, $line);
+ my $Chrom=$Line[0];
+ my $Start=$Line[3];
+ my $Stop=$Line[4];
+ my $ProbeName=$Line[5];
+ my $feature="ciccio";
+ if ($Chrom eq $chrom) {
+ if(($Start<=$transcriptStart && $Stop>$transcriptStart) || ($Start<$transcriptStop && $Stop>=$transcriptStop) || ($Start>=$transcriptStart && $Stop<=$transcriptStop) ){
+ #print "sono entrato con start $Start stop $Stop e $transcriptStart e $transcriptStop\n";
+
+ for($i=0;$i<=$#exonStart;$i++) {
+ if ($strand eq "+"){
+ $exoncount1=$i+1;
+ $exoncount2=$exoncount1;
+ if($i==$#exonStart) {$exoncount2="last";}
+ }
+ if ($strand eq "-"){
+ $exoncount1=($#exonStart+1)-$i;
+ $exoncount2=$exoncount1;
+ if($i==0) {$exoncount2="last";}
+ }
+
+ if(($Start<=$exonStart[$i]) && ($i==0) && ($strand eq "+")){
+ $feature="$chrom\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tprom_exon $exoncount2\t$exoncount1";
+ $gene_cen{"$ref\t$geneName"}{$feature}.="$Chrom-$Start,";
+ last;
+ }
+ if(($Start<=$exonStop[$i]) && ($i==$#exonStart) && ($strand eq "-") && ($Stop>=$exonStop[$i])){
+ $feature="$chrom\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tprom_exon $exoncount2\t$exoncount1";
+ $gene_cen{"$ref\t$geneName"}{$feature}.="$Chrom-$Start,";
+ last;
+ }
+ if(($Start<=$exonStart[$i]) && ($Stop>$exonStart[$i])){
+ $feature="$chrom\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\t*intronexon $exoncount2\t$exoncount1";
+ $gene_cen{"$ref\t$geneName"}{$feature}.="$Chrom-$Start,";
+ last;
+ }
+ if(($Start>=$exonStart[$i]) && ($Stop<=$exonStop[$i])){
+ $feature="$chrom\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\texon $exoncount2\t$exoncount1";
+ $gene_cen{"$ref\t$geneName"}{$feature}.="$Chrom-$Start,";
+ last;
+ }
+ if(($Start<$exonStop[$i]) && ($Stop>$exonStop[$i])){
+ $feature="$chrom\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\t*exonintron $exoncount2\t$exoncount1";
+ $gene_cen{"$ref\t$geneName"}{$feature}.="$Chrom-$Start,";
+ last;
+ }
+ if(($Start>=$exonStop[$i]) && ($Stop<=$exonStart[$i+1]) && ($check==0)){
+ $feature="$chrom\t$transcriptStart\t$transcriptStop\t$strand\t$exoncount\tintron $exoncount2\t$exoncount1";
+ $gene_cen{"$ref\t$geneName"}{$feature}.="$Chrom-$Start,";
+ last;
+ }
+
+ }
+
+
+ }
+
+ }
+
+ }
+ }
+
+foreach $nome (keys %gene_cen){
+ foreach $description (keys %{$gene_cen {$nome}}) {
+ print OUTFILE1 "$nome\t$description\t$gene_cen{$nome}{$description}\n";
+
+ }
+
+}
+}
+close INFILE;
+close INFILE2;
+}
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/calcolo_p_v4_norm.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/calcolo_p_v4_norm.xml Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,187 @@
+
+ Tiling Expression Analizer
+ calcolo_p_v4_norm_intron.pl -opt ${ann_choice.type1} -log ${ann_choice.type_data} -ann ${ann_choice.ann} -wt ${ann_choice.wt} -treat ${ann_choice.treat} -out $output -fdr ${ann_choice.fdr} -pv ${ann_choice.pv} -norm ${ann_choice.norm} -rc ${ann_choice.rc} -fc ${ann_choice.summary_choice.fc} -exon ${ann_choice.type} -sum_met ${ann_choice.summary_choice.fc_output}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .. class:: infomark
+
+**What it does**
+
+TEA utilizes NimbleGen expression files in gff format and annotated table by ENO as INPUT FILES and generates a table with the expression value. When comparing two different conditions a Fold Change and a p-value are calculated.
+
+PLEASE, for more detailed information refer to the CARPET user Manual:
+click to download_ it.
+
+.. _download: /static/example_file/CARPET_userManual.zip
+
+--------
+
+**Parameters:**
+
+- **Analysis type:**
+ - **expression** analysis calculates an expression value for each transcript coming from the mean or the median of all matching probes
+ - **comparison** analysis calculate an expression value for each transcript in both conditions, then calculates a Fold Change for each transcript and a p-value based on t-Test distribution.
+- **Data type:**
+ - **log2 value:** the data is not converted in log2
+ - **raw value:** the data is converted in log2
+- **Normalization:** quantile normalization between the two chips (not necessary if analysis type is "expression")
+- **probe selection:**
+ - **internal exon:** only probes annotated as exons are used to calculate expression value.
+ - **all exon:** also probes annotated at the boundaries of introns/exons are used to calculate the expression value. (probes in intronexon position usually have lower signal)
+ - **last exon:** only probes in the last exon are used to calculate expression value. This analysis can be preferred for cDNA generated by oligo-dT RT, since 3' of transcripts are generally better represented.
+- **summary method:**
+ - **mean:** fold change for each gene is calculated based on the mean value
+ - **median:** fold change for each gene is calculated based on the median value
+ - **both:** both are used
+- **Fold change cutoff:** only transcripts with FC higher than cutoff are kept
+- **FDR:**
+ - **yes:** False Discovery Rate correction is applied (as described in Storie et al. 2002)
+ - **no:** No correction --> raw p-value
+- **p-value cutoff:** only transcripts with p-value less than cutoff are kept
+- **raw value cutoff (log2):** only transcripts with raw value higher than cutoff at least in one experiment are kept
+
+--------
+
+
+**INPUT FILE**
+
+Nimblegen gives you back a GFF file with the coordinates of each probe and the signal raw value.
+
+Click here_ to download a GFF file example.
+
+.. _here: /static/example_file/Expression_analysis_files.zip
+
+
+Example of Nimblegen Expression GFF format::
+
+ chr19 Nimblegen tiling_array 100000 1000051 20459 + . probe_name
+ chr19 Nimblegen tiling_array 100100 1000151 1394 + . probe_name
+
+.. class:: warningmark
+
+The sixth column **must** contain the raw signal (**NOT** log2) that Nimblegen gives you back after the experiment
+
+The annotation table **MUST** be created usign ENO tool, before running TEA.
+
+---------
+
+.. class:: infomark
+
+**How does it work?**
+
+For each gene is built the signal distibution of the probes matching Exon.
+
+-In an expression experiment, the mean or the median of the distribution represents the result of Tea.
+
+-In a comparison experiment the distibution of the gene exon signal is compared between the two conditions (1 and 2) and a t-test is performed with the possibility to introduce FDR correction.
+
+.. image:: static/images/CARPET/Tea.png
+
+
+
+
+**OUTPUT**
+
+- **expresion**
+
+.. image:: static/images/CARPET/expression.png
+
+- **comparison**
+
+.. image:: static/images/CARPET/comparison.png
+
+
+
+
+
diff -r 000000000000 -r cdd489d98766 carpet-src-1/tools/CARPET/calcolo_p_v4_norm_intron.pl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/carpet-src-1/tools/CARPET/calcolo_p_v4_norm_intron.pl Tue Jun 07 16:50:41 2011 -0400
@@ -0,0 +1,636 @@
+#! /usr/bin/perl
+
+# Copyright 2009 Matteo Cesaroni, Lucilla Luzi
+#
+# This program is free software; ; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser 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.
+
+
+
+#prende tutte le probes che mecciano almeno in parte dentro gli esoni
+
+use Statistics::PointEstimation;
+use Statistics::TTest;
+#use Statistics::Test::WilcoxonRankSum;
+use Getopt::Long;
+
+GetOptions (
+ "help" => \$OPT{help},
+ "ann=s" => \$OPT{ann},
+ "wt=s" => \$OPT{wt},
+ "treat=s" => \$OPT{treat},
+ "out=s" => \$OPT{out},
+ "pv=s" => \$OPT{prob},
+ "rc=s" => \$OPT{raw_cut},
+ "fc=s" => \$OPT{fc_cut},
+ "exon=s" => \$OPT{exon},
+ "opt=s" => \$OPT{option},
+ "norm=s" =>\$OPT{norm_q},
+ "sum_met=s" =>\$OPT{sum_met},
+ "fdr=s" =>\$OPT{fdr},
+ "log=s" =>\$OPT{log_t},
+)|| printusage();
+
+# opzioni da linea di comando
+my $file_ann=$OPT{ann};
+my $file_wt=$OPT{wt};
+my $file_treat=$OPT{treat};
+my $file_output=$OPT{out};
+my $pv_cut=$OPT{prob};
+my $media_cut=$OPT{raw_cut};
+my $FC_cut=$OPT{fc_cut};
+my $tipo=$OPT{exon};
+my $option=$OPT{option};
+my $normalization_q=$OPT{norm_q};
+my $sum_meth=$OPT{sum_met};
+my $corretction=$OPT{fdr};
+my $data_log=$OPT{log_t};
+
+$help and printusage();
+
+
+if($option eq "comp"){
+if ($sum_meth eq "both"){
+$header=<$file_output") || die "bed_$file_wt not open:$!\n";
+
+print output "$header";
+
+print "Comparison --> probe_selection=$tipo, Normalization=$normalization_q, summary method=$sum_meth Filters: p-value=$pv_cut, raw value=$media_cut, FC=$FC_cut";
+
+while (defined (my $line_down = )) {
+ chomp $line_down;
+ my @tmp_down = split("\t", $line_down);
+ my @probe_match=split("\,", $tmp_down[9]);
+ foreach $probes (@probe_match){
+ my @coord=split("-", $probes);
+ $tab_tot{$tmp_down[0]}{"$coord[0]\t$coord[1]"}.="$tmp_down[1]\n$tmp_down[7]\n$tmp_down[0]\n$tmp_down[2]\n$tmp_down[3]\n$tmp_down[4]\n$tmp_down[5]\n$tmp_down[6]\n";
+ push(@ciclo,"$tmp_down[0]\t$coord[0]\t$coord[1]");
+ }
+}
+
+while (defined (my $line_down = )) {
+ chomp $line_down;
+ my @tmp_down = split("\t", $line_down);
+ chomp $tmp_down[0];
+ $tab_tot_wt{"$tmp_down[0]\t$tmp_down[3]"}=$tmp_down[5];
+}
+
+
+while (defined (my $line_down = )) {
+ chomp $line_down;
+ my @tmp_down = split("\t", $line_down);
+ chomp $tmp_down[0];
+ $tab_tot_treat{"$tmp_down[0]\t$tmp_down[3]"}=$tmp_down[5];
+}
+
+if($normalization_q eq "yes"){
+
+ @sort_wt=sort{$tab_tot_wt{$a} <=> $tab_tot_wt{$b}} keys %tab_tot_wt;
+ @sort_treat=sort{$tab_tot_treat{$a} <=> $tab_tot_treat{$b}} (keys %tab_tot_treat);
+
+ for($i=0;$i<=$#sort_wt;$i++){
+ $media=($tab_tot_wt{$sort_wt[$i]}+$tab_tot_treat{$sort_treat[$i]})/2;
+ $tab_tot_value{$sort_wt[$i]}.="$media\n";
+ }
+
+ for($i=0;$i<=$#sort_treat;$i++){
+ $media=($tab_tot_wt{$sort_wt[$i]}+$tab_tot_treat{$sort_treat[$i]})/2;
+ $tab_tot_value{$sort_treat[$i]}.="$media\n";
+ }
+
+}
+
+
+foreach $key_value(@ciclo){
+
+ @keys_values=split("\t",$key_value);
+ @array1= split("\n",$tab_tot{$keys_values[0]}{"$keys_values[1]\t$keys_values[2]"});
+ if($normalization_q eq "yes"){
+ @array2= split("\n",$tab_tot_value{"$keys_values[1]\t$keys_values[2]"});
+ $value1=$array2[0];
+ $value2=$array2[1];
+ }
+ else{
+ $value1=$tab_tot_wt{"$keys_values[1]\t$keys_values[2]"};
+ $value2=$tab_tot_treat{"$keys_values[1]\t$keys_values[2]"};
+ }
+ if ($tipo eq "internal_exon"){
+ $prendo = "^exon";
+ }
+ if ($tipo eq "all_exon"){
+ $prendo = "exon";
+ }
+ if ($tipo eq "last_exon"){
+ $prendo = "exon last";
+ }
+
+ if ((!($array1[0] eq "")) && ($array1[1] =~ /$prendo/g)) {
+ if ($data_log eq "no_log"){
+ $log1=log($value1)/log(2);
+ $log2=log($value2)/log(2);
+ }
+ if ($data_log eq "log"){
+ $log1=$value1;
+ $log2=$value2;
+ }
+ $tab_gene_wt{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log1\n";
+ $tab_gene_tratted{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log2\n";
+ }
+
+}
+
+foreach $key (keys %tab_gene_wt) {
+ @r1=split("\n",$tab_gene_wt{$key});
+ @r2=split("\n",$tab_gene_tratted{$key});
+
+ sort {$a <=> $b} (@r1);
+ sort {$a <=> $b} (@r2);
+
+ if ($#r1>0){
+ my $ttest = new Statistics::TTest;
+ $ttest->set_significance(95);
+ $ttest->load_data(\@r1,\@r2);
+ my $s1=$ttest->{s1};
+ my $s2=$ttest->{s2};
+ $media1=$s1->{mean};
+ $media2=$s2->{mean};
+ $total_probes=$#r1+1;
+ $potenza_a=$media2-$media1;
+ $FCa=((2)**$potenza_a);
+ if( (@r1 % 2) == 1 ) {
+ $median1 = $r1[((@r1+1) / 2)-1];
+ $median2 = $r2[((@r2+1) / 2)-1];
+ } else {
+ $median1 = ($r1[(@r1 / 2)-1] + $r1[@r1 / 2]) / 2;
+ $median2 = ($r2[(@r2 / 2)-1] + $r2[@r2 / 2]) / 2;
+ }
+ $potenza_m=$median2-$median1;
+ $FCm=((2)**$potenza_m);
+
+
+ if ($FCa<1){
+ $FCa=(-(1/$FCa));
+ }
+
+
+ if ($FCm<1){
+ $FCm=(-(1/$FCm));
+ }
+ if ($sum_meth eq "mean"){
+ if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCa))){
+ next;
+ }
+ $p_value{"$key\t$media1\t$media2\t$FCa\t$total_probes"}=$ttest->{t_prob};
+
+ #print output "$key\t$media1\t$media2\t$FCa\t",$ttest->{t_prob},"\t$total_probes\n";
+ }
+ if ($sum_meth eq "median"){
+ if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCm))){
+ next;
+ }
+ #print output "$key\t$median1\t$median2\t$FCm\t",$ttest->{t_prob},"\t$total_probes\n";
+ $p_value{"$key\t$median1\t$median2\t$FCm\t$total_probes"}=$ttest->{t_prob};
+ }
+ if ($sum_meth eq "both"){
+ if (($media1<$media_cut) && ($media2<$media_cut)){
+ next;
+ }
+ #print output "$key\t$media1\t$media2\t$FCa\t$median1\t$median2\t$FCm\t",$ttest->{t_prob},"\t$total_probes\n";
+ $p_value{"$key\t$media1\t$media2\t$FCa\t$median1\t$median2\t$FCm\t$total_probes"}=$ttest->{t_prob};
+ }
+ }
+ if ($#r1==0){
+ $media1=$r1[0];
+ $media2=$r2[0];
+ $median1=$r1[0];
+ $median2=$r2[0];
+ $potenza=$media2-$media1;
+ $FCa=((2)**$potenza);
+ $FCm=((2)**$potenza);
+ if ($FCa<1){
+ $FCa=(-(1/$FCa));
+ }
+ if ($FCm<1){
+ $FCm=(-(1/$FCm));
+ }
+
+ if ($sum_meth eq "both"){
+ if (($media1<$media_cut) && ($media2<$media_cut)){
+ next;
+ }
+ $p_value{"$key\t$media1\t$media2\t$FCa\t$median1\t$median2\t$FCm\t$total_probes"}=1;
+ }
+ if ($sum_meth eq "mean"){
+ if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCa))){
+ next;
+ }
+ $p_value{"$key\t$media1\t$media2\t$FCa\t$total_probes"}=1;
+ }
+ if ($sum_meth eq "median"){
+ if ((($media1<$media_cut) && ($media2<$media_cut)) || ($FC_cut>=abs($FCm))){
+ next;
+ }
+ $p_value{"$key\t$median1\t$median2\t$FCm\t$total_probes"}=1;
+ }
+ }
+}
+
+@sort_pvalue=sort{$p_value{$a} <=> $p_value{$b}} keys %p_value;
+
+if($corretction eq "yes"){
+ for($i=0;$i<=$#sort_pvalue;$i++){
+ $qvalue=$p_value{$sort_pvalue[$i]}*(($#sort_pvalue+1)/($i+1));
+ push(@QVALUE, $qvalue);
+ }
+
+ @qvalue_sort = sort {$a <=> $b} @QVALUE;
+
+ for($i=0;$i<=$#sort_pvalue;$i++){
+ #$FDR=((($i+1)*0.05)/($#sort_pvalue+1));
+ $qvalue=shift(@qvalue_sort);
+ if($qvalue>1){$qvalue=1;}
+ if($pv_cut>=$qvalue){
+ print output "$sort_pvalue[$i]\t$p_value{$sort_pvalue[$i]}\t$qvalue\n";
+ }
+ }
+}
+if($corretction eq "no"){
+ for($i=0;$i<=$#sort_pvalue;$i++){
+ if($pv_cut>=$qvalue){
+ print output "$sort_pvalue[$i]\t$p_value{$sort_pvalue[$i]}\n";
+ }
+ }
+}
+
+
+
+
+
+}
+if($option eq "expr"){
+if ($sum_meth eq "median"){
+$header=<$file_output") || die "bed_$file_wt not open:$!\n";
+
+print output "$header";
+
+print "Expression --> probe_selection=$tipo summary method=$sum_meth";
+
+while (defined (my $line_down = )) {
+ chomp $line_down;
+ my @tmp_down = split("\t", $line_down);
+ my @probe_match=split("\,", $tmp_down[9]);
+ foreach $probes (@probe_match){
+ my @coord=split("-", $probes);
+ $tab_tot{$tmp_down[0]}{"$coord[0]\t$coord[1]"}.="$tmp_down[1]\n$tmp_down[7]\n$tmp_down[0]\n$tmp_down[2]\n$tmp_down[3]\n$tmp_down[4]\n$tmp_down[5]\n$tmp_down[6]\n";
+ push(@ciclo,"$tmp_down[0]\t$coord[0]\t$coord[1]");
+ }
+}
+
+while (defined (my $line_down = )) {
+ chomp $line_down;
+ $line_down=~ s/ //g;
+ my @tmp_down = split("\t", $line_down);
+ chomp $tmp_down[0];
+ $tab_tot_wt{"$tmp_down[0]\t$tmp_down[3]"}=$tmp_down[5];
+}
+#@sort_wt=sort{$tab_tot_wt{$a} <=> $tab_tot_wt{$b}} keys %tab_tot_wt;
+
+
+#print "ciclo = $ciclo[0]\t$ciclo[1]\n";
+
+foreach $key_value(@ciclo){
+
+ @keys_values=split("\t",$key_value);
+ @array1= split("\n",$tab_tot{$keys_values[0]}{"$keys_values[1]\t$keys_values[2]"});
+ @array2= split("\n",$tab_tot_wt{"$keys_values[1]\t$keys_values[2]"});
+
+ if ($tipo eq "internal_exon"){
+ $prendo = "^exon";
+ }
+ if ($tipo eq "all_exon"){
+ $prendo = "exon";
+ }
+ if ($tipo eq "last_exon"){
+ $prendo = "exon last";
+ }
+
+ if ((!($array1[0] eq "")) && ($array1[1] =~ /$prendo/g)) {
+
+ if ($data_log eq "no_log"){
+ $log1=log($array2[0])/log(2);
+ }
+ if ($data_log eq "log"){
+ $log1=$array2[0];
+ }
+
+ $tab_gene_wt{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log1\n";
+ }
+ if ((!($array1[0] eq "")) && ($array1[1] =~ /intron/g)) {
+ if ($data_log eq "no_log"){
+ $log1=log($array2[0])/log(2);
+ }
+ if ($data_log eq "log"){
+ $log1=$array2[0];
+ }
+ $tab_intron_wt{"$array1[0]\t$array1[2]\t$array1[3]\t$array1[4]\t$array1[5]\t$array1[6]"}.="$log1\n";
+ }
+
+}
+
+
+foreach $key (keys %tab_gene_wt) {
+ @r1=split("\n",$tab_gene_wt{$key});
+ if (exists $tab_intron_wt{$key}){
+ @r2=split("\n",$tab_intron_wt{$key});
+ sort {$a <=> $b} (@r2);
+ }else{
+ @r2=("no");
+ }
+ sort {$a <=> $b} (@r1);
+ if ($#r2>0) {
+ if ($#r1>0) {
+ my $ttest = new Statistics::TTest;
+ $ttest->set_significance(95);
+ $ttest->load_data(\@r1,\@r2);
+ my $s1=$ttest->{s1};
+ my $s2=$ttest->{s2};
+ $media1=$s1->{mean};
+ $media2=$s2->{mean};
+ $total_probes=$#r1+1;
+ $total_probes2=$#r2+1;
+ if( (@r1 % 2) == 1 ) {
+ $median1 = $r1[((@r1+1) / 2)-1];
+ } else {
+ $median1 = ($r1[(@r1 / 2)-1] + $r1[@r1 / 2]) / 2;
+ }
+ if( (@r2 % 2) == 1 ) {
+ $median2 = $r2[((@r2+1) / 2)-1];
+ } else {
+ $median2 = ($r2[(@r2 / 2)-1] + $r2[@r2 / 2]) / 2;
+ }
+ if($media1>=$media2){
+ $pvalue=$ttest->{t_prob};
+ }
+ if($media1<$media2){
+ $pvalue=1;
+ }
+ if ($sum_meth eq "mean"){
+ print output "$key\t$media1\t$media2\t$pvalue\t$total_probes\t$total_probes2\n";
+ #print output "$key\t$media1\t$total_probes\n";
+ }
+ if ($sum_meth eq "median"){
+ print output "$key\t$median1\t$median2\t$pvalue\t$total_probes\t$total_probes2\n";
+ #print output "$key\t$median1\t$total_probes\n";
+ }
+ if ($sum_meth eq "both"){
+ print output "$key\t$media1\t$media2\t$median1\t$median2\t$pvalue\t$total_probes\t$total_probes2\n";
+ #print output "$key\t$media1\t$median1\t$total_probes\n";
+ }
+ }
+ if ($#r1==0) {
+ @r1=@r2;
+ my $ttest = new Statistics::TTest;
+ $ttest->set_significance(95);
+ $ttest->load_data(\@r1,\@r2);
+ my $s2=$ttest->{s2};
+ $media2=$s2->{mean};
+ $total_probes=1;
+ $total_probes2=$#r2+1;
+ $media1=$r1[0];
+ $median1=$r1[0];
+ if( (@r2 % 2) == 1 ) {
+ $median2 = $r2[((@r2+1) / 2)-1];
+ } else {
+ $median2 = ($r2[(@r2 / 2)-1] + $r2[@r2 / 2]) / 2;
+ }
+ if ($sum_meth eq "mean"){
+ print output "$key\t$media1\t$media2\tNA\t$total_probes\t$total_probes2\n";
+ #print output "$key\t$media1\t$total_probes\n";
+ }
+ if ($sum_meth eq "median"){
+ print output "$key\t$median1\t$median2\tNA\t$total_probes\t$total_probes2\n";
+ #print output "$key\t$median1\t$total_probes\n";
+ }
+ if ($sum_meth eq "both"){
+ print output "$key\t$media1\t$media2\t$median1\t$median2\tNA\t$total_probes\t$total_probes2\n";
+ #print output "$key\t$media1\t$median1\t$total_probes\n";
+ }
+ }
+
+
+ }
+
+ if ($r2[0] eq "no") {
+ if ($#r1>0) {
+ @r2=@r1;
+ my $ttest = new Statistics::TTest;
+ $ttest->set_significance(95);
+ $ttest->load_data(\@r1,\@r2);
+ my $s1=$ttest->{s1};
+ $media1=$s1->{mean};
+ $total_probes=$#r1+1;
+ if( (@r1 % 2) == 1 ) {
+ $median1 = $r1[((@r1+1) / 2)-1];
+ } else {
+ $median1 = ($r1[(@r1 / 2)-1] + $r1[@r1 / 2]) / 2;
+ }
+ }
+ if ($#r==0){
+ $media1=$r1[0];
+ $median1=$r1[0];
+ $total_probes=$#r1+1;
+ }
+ $media2=0;
+ $median2=0;
+ if ($sum_meth eq "both"){
+ print output "$key\t$media1\t$media2\t$median1\t$median2\tNA\t$total_probes\t0\n";
+ #print output "$key\t$media1\t$median1\t$total_probes\n";
+ }
+ if ($sum_meth eq "mean"){
+ print output "$key\t$media1\t$media2\tNA\t$total_probes\t0\n";
+ #print output "$key\t$media1\t$total_probes\n";
+ }
+ if ($sum_meth eq "median"){
+ print output "$key\t$median1\t$median2\tNA\t$total_probes\t0\n";
+ #print output "$key\t$median1\t$total_probes\n";
+ }
+ }
+ if (($#r2 == 0) && ($r2[0] ne "no") && ($#r1==0)){
+ $media1=$r1[0];
+ $media2=$r2[0];
+ $median1=$r1[0];
+ $median2=$r2[0];
+ if ($sum_meth eq "both"){
+ print output "$key\t$media1\t$media2\t$median1\t$median2\tNA\t1\t1\n";
+ #print output "$key\t$media1\t$median1\t1\n";
+ }
+ if ($sum_meth eq "mean"){
+ print output "$key\t$media1\t$media2\tNA\t1\t1\n";
+ #print output "$key\t$media1\t1\n";
+ }
+ if ($sum_meth eq "median"){
+ print output "$key\t$median1\t$median2\tNA\t1\t1\n";
+ #print output "$key\t$median1\t1\n";
+ }
+ }
+}
+
+
+
+
+}
+
+
+
+
+
+####################################################################################################################################
+
+sub printusage {
+
+ print<
+#include
+#include
+#include
+#include
+#include
+#include
+#include