From 8b4133a94a4aaace9f228e2f22afb992664ac6cd Mon Sep 17 00:00:00 2001 From: GAUTREAU Guillaume Date: Sun, 1 Jul 2018 16:02:34 +0200 Subject: [PATCH] update VERSION 0.1.0 --- LICENSE.txt | 519 ++++++++ MANIFEST.in | 6 +- README.rst | 14 +- VERSION | 2 +- ppanggolin/NEM/err2.c | 104 -- ppanggolin/NEM/exemain.c | 32 - ppanggolin/NEM/{exememo.c => genmemo.c} | 4 +- ppanggolin/NEM/geo2nei.c | 787 ------------ ppanggolin/NEM/mainfunc.h | 13 - ppanggolin/NEM/makefile | 258 ---- ppanggolin/NEM/nem.pyx | 14 + ppanggolin/NEM/nem_alg.c | 75 +- ppanggolin/NEM/nem_arg.c | 1315 ------------------- ppanggolin/NEM/nem_arg.h | 23 - ppanggolin/NEM/nem_exe.c | 825 +++++++----- ppanggolin/NEM/nem_exe.h | 36 + ppanggolin/NEM/nem_rnd2.h | 10 - ppanggolin/NEM/nem_typ.h | 105 +- ppanggolin/NEM/nem_user.txt | 615 --------- ppanggolin/NEM/randord.c | 134 -- ppanggolin/NEM/tcpu.c | 41 - ppanggolin/NEM/txt2hlp.c | 232 ---- ppanggolin/__init__.py | 2 +- ppanggolin/command_line.py | 463 +++---- ppanggolin/ppanggolin.py | 1549 ++++++++++++++++------- ppanggolin/utils.py | 131 ++ setup.py | 60 +- 27 files changed, 2754 insertions(+), 4615 deletions(-) create mode 100755 LICENSE.txt mode change 100644 => 100755 MANIFEST.in mode change 100644 => 100755 README.rst mode change 100644 => 100755 VERSION delete mode 100755 ppanggolin/NEM/err2.c delete mode 100755 ppanggolin/NEM/exemain.c rename ppanggolin/NEM/{exememo.c => genmemo.c} (97%) delete mode 100755 ppanggolin/NEM/geo2nei.c delete mode 100755 ppanggolin/NEM/mainfunc.h delete mode 100755 ppanggolin/NEM/makefile create mode 100755 ppanggolin/NEM/nem.pyx delete mode 100755 ppanggolin/NEM/nem_arg.c delete mode 100755 ppanggolin/NEM/nem_arg.h create mode 100755 ppanggolin/NEM/nem_exe.h delete mode 100755 ppanggolin/NEM/nem_rnd2.h delete mode 100755 ppanggolin/NEM/nem_user.txt delete mode 100755 ppanggolin/NEM/randord.c delete mode 100755 ppanggolin/NEM/tcpu.c delete mode 100755 ppanggolin/NEM/txt2hlp.c mode change 100644 => 100755 ppanggolin/__init__.py mode change 100755 => 100644 ppanggolin/ppanggolin.py create mode 100755 ppanggolin/utils.py mode change 100644 => 100755 setup.py diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100755 index 00000000..b705f37a --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,519 @@ + + CeCILL FREE SOFTWARE LICENSE AGREEMENT + +Version 2.1 dated 2013-06-21 + + + Notice + +This Agreement is a Free Software license agreement that is the result +of discussions between its authors in order to ensure compliance with +the two main principles guiding its drafting: + + * firstly, compliance with the principles governing the distribution + of Free Software: access to source code, broad rights granted to users, + * secondly, the election of a governing law, French law, with which it + is conformant, both as regards the law of torts and intellectual + property law, and the protection that it offers to both authors and + holders of the economic rights over software. + +The authors of the CeCILL (for Ce[a] C[nrs] I[nria] L[ogiciel] L[ibre]) +license are: + +Commissariat à l'énergie atomique et aux énergies alternatives - CEA, a +public scientific, technical and industrial research establishment, +having its principal place of business at 25 rue Leblanc, immeuble Le +Ponant D, 75015 Paris, France. + +Centre National de la Recherche Scientifique - CNRS, a public scientific +and technological establishment, having its principal place of business +at 3 rue Michel-Ange, 75794 Paris cedex 16, France. + +Institut National de Recherche en Informatique et en Automatique - +Inria, a public scientific and technological establishment, having its +principal place of business at Domaine de Voluceau, Rocquencourt, BP +105, 78153 Le Chesnay cedex, France. + + + Preamble + +The purpose of this Free Software license agreement is to grant users +the right to modify and redistribute the software governed by this +license within the framework of an open source distribution model. + +The exercising of this right is conditional upon certain obligations for +users so as to preserve this status for all subsequent redistributions. + +In consideration of access to the source code and the rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors only have limited liability. + +In this respect, the risks associated with loading, using, modifying +and/or developing or reproducing the software by the user are brought to +the user's attention, given its Free Software status, which may make it +complicated to use, with the result that its use is reserved for +developers and experienced professionals having in-depth computer +knowledge. Users are therefore encouraged to load and test the +suitability of the software as regards their requirements in conditions +enabling the security of their systems and/or data to be ensured and, +more generally, to use and operate it in the same conditions of +security. This Agreement may be freely reproduced and published, +provided it is not altered, and that no provisions are either added or +removed herefrom. + +This Agreement may apply to any or all software for which the holder of +the economic rights decides to submit the use thereof to its provisions. + +Frequently asked questions can be found on the official website of the +CeCILL licenses family (http://www.cecill.info/index.en.html) for any +necessary clarification. + + + Article 1 - DEFINITIONS + +For the purpose of this Agreement, when the following expressions +commence with a capital letter, they shall have the following meaning: + +Agreement: means this license agreement, and its possible subsequent +versions and annexes. + +Software: means the software in its Object Code and/or Source Code form +and, where applicable, its documentation, "as is" when the Licensee +accepts the Agreement. + +Initial Software: means the Software in its Source Code and possibly its +Object Code form and, where applicable, its documentation, "as is" when +it is first distributed under the terms and conditions of the Agreement. + +Modified Software: means the Software modified by at least one +Contribution. + +Source Code: means all the Software's instructions and program lines to +which access is required so as to modify the Software. + +Object Code: means the binary files originating from the compilation of +the Source Code. + +Holder: means the holder(s) of the economic rights over the Initial +Software. + +Licensee: means the Software user(s) having accepted the Agreement. + +Contributor: means a Licensee having made at least one Contribution. + +Licensor: means the Holder, or any other individual or legal entity, who +distributes the Software under the Agreement. + +Contribution: means any or all modifications, corrections, translations, +adaptations and/or new functions integrated into the Software by any or +all Contributors, as well as any or all Internal Modules. + +Module: means a set of sources files including their documentation that +enables supplementary functions or services in addition to those offered +by the Software. + +External Module: means any or all Modules, not derived from the +Software, so that this Module and the Software run in separate address +spaces, with one calling the other when they are run. + +Internal Module: means any or all Module, connected to the Software so +that they both execute in the same address space. + +GNU GPL: means the GNU General Public License version 2 or any +subsequent version, as published by the Free Software Foundation Inc. + +GNU Affero GPL: means the GNU Affero General Public License version 3 or +any subsequent version, as published by the Free Software Foundation Inc. + +EUPL: means the European Union Public License version 1.1 or any +subsequent version, as published by the European Commission. + +Parties: mean both the Licensee and the Licensor. + +These expressions may be used both in singular and plural form. + + + Article 2 - PURPOSE + +The purpose of the Agreement is the grant by the Licensor to the +Licensee of a non-exclusive, transferable and worldwide license for the +Software as set forth in Article 5 <#scope> hereinafter for the whole +term of the protection granted by the rights over said Software. + + + Article 3 - ACCEPTANCE + +3.1 The Licensee shall be deemed as having accepted the terms and +conditions of this Agreement upon the occurrence of the first of the +following events: + + * (i) loading the Software by any or all means, notably, by + downloading from a remote server, or by loading from a physical medium; + * (ii) the first time the Licensee exercises any of the rights granted + hereunder. + +3.2 One copy of the Agreement, containing a notice relating to the +characteristics of the Software, to the limited warranty, and to the +fact that its use is restricted to experienced users has been provided +to the Licensee prior to its acceptance as set forth in Article 3.1 +<#accepting> hereinabove, and the Licensee hereby acknowledges that it +has read and understood it. + + + Article 4 - EFFECTIVE DATE AND TERM + + + 4.1 EFFECTIVE DATE + +The Agreement shall become effective on the date when it is accepted by +the Licensee as set forth in Article 3.1 <#accepting>. + + + 4.2 TERM + +The Agreement shall remain in force for the entire legal term of +protection of the economic rights over the Software. + + + Article 5 - SCOPE OF RIGHTS GRANTED + +The Licensor hereby grants to the Licensee, who accepts, the following +rights over the Software for any or all use, and for the term of the +Agreement, on the basis of the terms and conditions set forth hereinafter. + +Besides, if the Licensor owns or comes to own one or more patents +protecting all or part of the functions of the Software or of its +components, the Licensor undertakes not to enforce the rights granted by +these patents against successive Licensees using, exploiting or +modifying the Software. If these patents are transferred, the Licensor +undertakes to have the transferees subscribe to the obligations set +forth in this paragraph. + + + 5.1 RIGHT OF USE + +The Licensee is authorized to use the Software, without any limitation +as to its fields of application, with it being hereinafter specified +that this comprises: + + 1. permanent or temporary reproduction of all or part of the Software + by any or all means and in any or all form. + + 2. loading, displaying, running, or storing the Software on any or all + medium. + + 3. entitlement to observe, study or test its operation so as to + determine the ideas and principles behind any or all constituent + elements of said Software. This shall apply when the Licensee + carries out any or all loading, displaying, running, transmission or + storage operation as regards the Software, that it is entitled to + carry out hereunder. + + + 5.2 ENTITLEMENT TO MAKE CONTRIBUTIONS + +The right to make Contributions includes the right to translate, adapt, +arrange, or make any or all modifications to the Software, and the right +to reproduce the resulting software. + +The Licensee is authorized to make any or all Contributions to the +Software provided that it includes an explicit notice that it is the +author of said Contribution and indicates the date of the creation thereof. + + + 5.3 RIGHT OF DISTRIBUTION + +In particular, the right of distribution includes the right to publish, +transmit and communicate the Software to the general public on any or +all medium, and by any or all means, and the right to market, either in +consideration of a fee, or free of charge, one or more copies of the +Software by any means. + +The Licensee is further authorized to distribute copies of the modified +or unmodified Software to third parties according to the terms and +conditions set forth hereinafter. + + + 5.3.1 DISTRIBUTION OF SOFTWARE WITHOUT MODIFICATION + +The Licensee is authorized to distribute true copies of the Software in +Source Code or Object Code form, provided that said distribution +complies with all the provisions of the Agreement and is accompanied by: + + 1. a copy of the Agreement, + + 2. a notice relating to the limitation of both the Licensor's warranty + and liability as set forth in Articles 8 and 9, + +and that, in the event that only the Object Code of the Software is +redistributed, the Licensee allows effective access to the full Source +Code of the Software for a period of at least three years from the +distribution of the Software, it being understood that the additional +acquisition cost of the Source Code shall not exceed the cost of the +data transfer. + + + 5.3.2 DISTRIBUTION OF MODIFIED SOFTWARE + +When the Licensee makes a Contribution to the Software, the terms and +conditions for the distribution of the resulting Modified Software +become subject to all the provisions of this Agreement. + +The Licensee is authorized to distribute the Modified Software, in +source code or object code form, provided that said distribution +complies with all the provisions of the Agreement and is accompanied by: + + 1. a copy of the Agreement, + + 2. a notice relating to the limitation of both the Licensor's warranty + and liability as set forth in Articles 8 and 9, + +and, in the event that only the object code of the Modified Software is +redistributed, + + 3. a note stating the conditions of effective access to the full source + code of the Modified Software for a period of at least three years + from the distribution of the Modified Software, it being understood + that the additional acquisition cost of the source code shall not + exceed the cost of the data transfer. + + + 5.3.3 DISTRIBUTION OF EXTERNAL MODULES + +When the Licensee has developed an External Module, the terms and +conditions of this Agreement do not apply to said External Module, that +may be distributed under a separate license agreement. + + + 5.3.4 COMPATIBILITY WITH OTHER LICENSES + +The Licensee can include a code that is subject to the provisions of one +of the versions of the GNU GPL, GNU Affero GPL and/or EUPL in the +Modified or unmodified Software, and distribute that entire code under +the terms of the same version of the GNU GPL, GNU Affero GPL and/or EUPL. + +The Licensee can include the Modified or unmodified Software in a code +that is subject to the provisions of one of the versions of the GNU GPL, +GNU Affero GPL and/or EUPL and distribute that entire code under the +terms of the same version of the GNU GPL, GNU Affero GPL and/or EUPL. + + + Article 6 - INTELLECTUAL PROPERTY + + + 6.1 OVER THE INITIAL SOFTWARE + +The Holder owns the economic rights over the Initial Software. Any or +all use of the Initial Software is subject to compliance with the terms +and conditions under which the Holder has elected to distribute its work +and no one shall be entitled to modify the terms and conditions for the +distribution of said Initial Software. + +The Holder undertakes that the Initial Software will remain ruled at +least by this Agreement, for the duration set forth in Article 4.2 <#term>. + + + 6.2 OVER THE CONTRIBUTIONS + +The Licensee who develops a Contribution is the owner of the +intellectual property rights over this Contribution as defined by +applicable law. + + + 6.3 OVER THE EXTERNAL MODULES + +The Licensee who develops an External Module is the owner of the +intellectual property rights over this External Module as defined by +applicable law and is free to choose the type of agreement that shall +govern its distribution. + + + 6.4 JOINT PROVISIONS + +The Licensee expressly undertakes: + + 1. not to remove, or modify, in any manner, the intellectual property + notices attached to the Software; + + 2. to reproduce said notices, in an identical manner, in the copies of + the Software modified or not. + +The Licensee undertakes not to directly or indirectly infringe the +intellectual property rights on the Software of the Holder and/or +Contributors, and to take, where applicable, vis-à-vis its staff, any +and all measures required to ensure respect of said intellectual +property rights of the Holder and/or Contributors. + + + Article 7 - RELATED SERVICES + +7.1 Under no circumstances shall the Agreement oblige the Licensor to +provide technical assistance or maintenance services for the Software. + +However, the Licensor is entitled to offer this type of services. The +terms and conditions of such technical assistance, and/or such +maintenance, shall be set forth in a separate instrument. Only the +Licensor offering said maintenance and/or technical assistance services +shall incur liability therefor. + +7.2 Similarly, any Licensor is entitled to offer to its licensees, under +its sole responsibility, a warranty, that shall only be binding upon +itself, for the redistribution of the Software and/or the Modified +Software, under terms and conditions that it is free to decide. Said +warranty, and the financial terms and conditions of its application, +shall be subject of a separate instrument executed between the Licensor +and the Licensee. + + + Article 8 - LIABILITY + +8.1 Subject to the provisions of Article 8.2, the Licensee shall be +entitled to claim compensation for any direct loss it may have suffered +from the Software as a result of a fault on the part of the relevant +Licensor, subject to providing evidence thereof. + +8.2 The Licensor's liability is limited to the commitments made under +this Agreement and shall not be incurred as a result of in particular: +(i) loss due the Licensee's total or partial failure to fulfill its +obligations, (ii) direct or consequential loss that is suffered by the +Licensee due to the use or performance of the Software, and (iii) more +generally, any consequential loss. In particular the Parties expressly +agree that any or all pecuniary or business loss (i.e. loss of data, +loss of profits, operating loss, loss of customers or orders, +opportunity cost, any disturbance to business activities) or any or all +legal proceedings instituted against the Licensee by a third party, +shall constitute consequential loss and shall not provide entitlement to +any or all compensation from the Licensor. + + + Article 9 - WARRANTY + +9.1 The Licensee acknowledges that the scientific and technical +state-of-the-art when the Software was distributed did not enable all +possible uses to be tested and verified, nor for the presence of +possible defects to be detected. In this respect, the Licensee's +attention has been drawn to the risks associated with loading, using, +modifying and/or developing and reproducing the Software which are +reserved for experienced users. + +The Licensee shall be responsible for verifying, by any or all means, +the suitability of the product for its requirements, its good working +order, and for ensuring that it shall not cause damage to either persons +or properties. + +9.2 The Licensor hereby represents, in good faith, that it is entitled +to grant all the rights over the Software (including in particular the +rights set forth in Article 5 <#scope>). + +9.3 The Licensee acknowledges that the Software is supplied "as is" by +the Licensor without any other express or tacit warranty, other than +that provided for in Article 9.2 <#good-faith> and, in particular, +without any warranty as to its commercial value, its secured, safe, +innovative or relevant nature. + +Specifically, the Licensor does not warrant that the Software is free +from any error, that it will operate without interruption, that it will +be compatible with the Licensee's own equipment and software +configuration, nor that it will meet the Licensee's requirements. + +9.4 The Licensor does not either expressly or tacitly warrant that the +Software does not infringe any third party intellectual property right +relating to a patent, software or any other property right. Therefore, +the Licensor disclaims any and all liability towards the Licensee +arising out of any or all proceedings for infringement that may be +instituted in respect of the use, modification and redistribution of the +Software. Nevertheless, should such proceedings be instituted against +the Licensee, the Licensor shall provide it with technical and legal +expertise for its defense. Such technical and legal expertise shall be +decided on a case-by-case basis between the relevant Licensor and the +Licensee pursuant to a memorandum of understanding. The Licensor +disclaims any and all liability as regards the Licensee's use of the +name of the Software. No warranty is given as regards the existence of +prior rights over the name of the Software or as regards the existence +of a trademark. + + + Article 10 - TERMINATION + +10.1 In the event of a breach by the Licensee of its obligations +hereunder, the Licensor may automatically terminate this Agreement +thirty (30) days after notice has been sent to the Licensee and has +remained ineffective. + +10.2 A Licensee whose Agreement is terminated shall no longer be +authorized to use, modify or distribute the Software. However, any +licenses that it may have granted prior to termination of the Agreement +shall remain valid subject to their having been granted in compliance +with the terms and conditions hereof. + + + Article 11 - MISCELLANEOUS + + + 11.1 EXCUSABLE EVENTS + +Neither Party shall be liable for any or all delay, or failure to +perform the Agreement, that may be attributable to an event of force +majeure, an act of God or an outside cause, such as defective +functioning or interruptions of the electricity or telecommunications +networks, network paralysis following a virus attack, intervention by +government authorities, natural disasters, water damage, earthquakes, +fire, explosions, strikes and labor unrest, war, etc. + +11.2 Any failure by either Party, on one or more occasions, to invoke +one or more of the provisions hereof, shall under no circumstances be +interpreted as being a waiver by the interested Party of its right to +invoke said provision(s) subsequently. + +11.3 The Agreement cancels and replaces any or all previous agreements, +whether written or oral, between the Parties and having the same +purpose, and constitutes the entirety of the agreement between said +Parties concerning said purpose. No supplement or modification to the +terms and conditions hereof shall be effective as between the Parties +unless it is made in writing and signed by their duly authorized +representatives. + +11.4 In the event that one or more of the provisions hereof were to +conflict with a current or future applicable act or legislative text, +said act or legislative text shall prevail, and the Parties shall make +the necessary amendments so as to comply with said act or legislative +text. All other provisions shall remain effective. Similarly, invalidity +of a provision of the Agreement, for any reason whatsoever, shall not +cause the Agreement as a whole to be invalid. + + + 11.5 LANGUAGE + +The Agreement is drafted in both French and English and both versions +are deemed authentic. + + + Article 12 - NEW VERSIONS OF THE AGREEMENT + +12.1 Any person is authorized to duplicate and distribute copies of this +Agreement. + +12.2 So as to ensure coherence, the wording of this Agreement is +protected and may only be modified by the authors of the License, who +reserve the right to periodically publish updates or new versions of the +Agreement, each with a separate number. These subsequent versions may +address new issues encountered by Free Software. + +12.3 Any Software distributed under a given version of the Agreement may +only be subsequently distributed under the same version of the Agreement +or a subsequent version, subject to the provisions of Article 5.3.4 +<#compatibility>. + + + Article 13 - GOVERNING LAW AND JURISDICTION + +13.1 The Agreement is governed by French law. The Parties agree to +endeavor to seek an amicable solution to any disagreements or disputes +that may arise during the performance of the Agreement. + +13.2 Failing an amicable solution within two (2) months as from their +occurrence, and unless emergency proceedings are necessary, the +disagreements or disputes shall be referred to the Paris Courts having +jurisdiction, by the more diligent Party. + diff --git a/MANIFEST.in b/MANIFEST.in old mode 100644 new mode 100755 index 2edb2050..22445940 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,5 @@ include README.rst -recursive-include ppanggolin nem_exe -recursive-include images +include VERSION +include LICENSE.txt +recursive-include images *.png *.gif +recursive-include ppanggolin * diff --git a/README.rst b/README.rst old mode 100644 new mode 100755 index 7d9ed198..e7f0bab7 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -PPanGGOLiN : Depicting microbial species diversity via a Partitioned Pangenome Graph +PPanGGOLiN : Depicting microbial species diversity via a Partitioned PanGenome Graph Of Linked Neighbors ========================================================================================= .. image:: images/logo.png @@ -25,7 +25,7 @@ PPanGGOLiN can be easily installed via: GCC (>=3.0) will be required, as well as Python 3 and the following modules : "networkx(>=2.00)", "ordered-set", "numpy", "scipy", "tqdm" and "python-highcharts" -Optionally, in order to draw illustrative plots, R will be required together with the following packages : ("ggplot2", "ggrepel(last version)", "reshape2" and "data.table") +Optionally, in order to draw illustrative plots, R will be required together with the following packages : ("ggplot2", "ggrepel(last version)", "reshape2", "minpack.lm" and "data.table") Quick usage ============================ @@ -169,7 +169,7 @@ For example, this command: will remove gene families having more than 10 repeated genes in at least one of the organism. Empirically, using a r-value of 10 will discard only few gene families (a dozen) . -Directed or Undirected graph (-ud option) +Undirected or Directed graph (-di option) ------------------------------------------------------ The pangenome graph can be directed or undirected. Directed graph provided more information but as genome can have multiple inversion around the origin of replication, it is sometime simpler to merge the directed edge into a undirected one. @@ -178,16 +178,16 @@ For example, this command : .. code:: bash - ppanggolin --organisms ORGANISMS_FILE --gene_families FAMILIES_FILE -o OUTPUT_DIR -ud + ppanggolin --organisms ORGANISMS_FILE --gene_families FAMILIES_FILE -o OUTPUT_DIR -di -Note that the partitioning method will not be impacted by this flag because in every case the partitioning approach considers the graph as undirected. +Will generate a directed pangenome graph. Note that the partitioning method will not be impacted by this flag because in every case the partitioning approach considers the graph as undirected. Partionning parameter --------------------------- The partitioning method can be customized via 3 parameters: -1. Partitioning by chunks (-ck VALUE option): When more than 500 organisms are processed it is advised to partition the pangenome by chunks. Actually, the method seems to saturate with an large number of dimensions. Chunks correspond to samples of the organisms to partition simultaneously. We advise to use chunks bigger than 200 organisms in order to obtain representative ones. Then the tools will partition the pangenome using multiple chunks in a way that every gene families must be partitionned in at least (total number of organisms)/(chunk size) times. Moreover each gene family must be partitionned mainly in one specific partition (>50% of cases), otherwise the partitioning will continue until validating this criteria. +1. Partitioning by chunks (-ck VALUE option): When more than 500 organisms are processed it is advised to partition the pangenome by chunks. Actually, the method seems to saturate with an large number of dimensions. Chunks correspond to samples of the organisms to partition simultaneously. We advise to use chunks of 500 organisms in order to obtain representative ones. Then the tools will partition the pangenome using multiple chunks in a way that every gene families must be partitionned in at least (total number of organisms)/(chunk size) times. Moreover each gene family must be partitionned mainly in one specific partition (>50% of cases), otherwise the partitioning will continue until validating this criteria. This feature can be executed using this command : @@ -216,7 +216,7 @@ Evolution curve (-e option) Contrary to a pangenome where gene families are partionned in core genome or accessory genome based on a threshold of occurences, this approach esimates the best partitionning via a statistical approach. Thereby this processing required calculation steps so that it is not instantaneous. Performing a lot of resampling can thus require heavy calculations and this why it is not achieved by default. Nevertheless, it is possible to perform these resampling using the -e flag. Use this flag with caution. -We also offer the possibility to customize the resampling using 4 parameters provided to the -ep option : RESAMPLING_RATIO, MINIMUN_SAMPLING, MAXIMUN_SAMPLING (See the figure below to obtain an idea of the effect of the 4 parameters). The last parameter allows jumping some combinations of organisms by a determined STEP to reduce the number of computation. For example purpose, to compute all the combinations (strongly discouraged !) RESAMPLING_RATIO must be equal to 1, MINIMUN_SAMPLING to 1, MAXIMUN_SAMPLING to Inf and STEP to 1. +We also offer the possibility to customize the resampling using 4 parameters provided to the -ep option : RESAMPLING_RATIO, MINIMUN_SAMPLING, MAXIMUN_SAMPLING, STEP and LIMIT (See the figure below to obtain an idea of the effect of the parameters). The STEP parameter allows jumping some combinations of organisms by a determined STEP to reduce the number of computation and the LIMIT parameter specify the maximun of sample size. For example purpose, to compute all the combinations (strongly discouraged !) RESAMPLING_RATIO must be equal to 1, MINIMUN_SAMPLING to 1, MAXIMUN_SAMPLING to Inf, STEP to 1 and LIMIT to Inf. .. image:: images/resampling.png diff --git a/VERSION b/VERSION old mode 100644 new mode 100755 index bcab45af..6e8bf73a --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.3 +0.1.0 diff --git a/ppanggolin/NEM/err2.c b/ppanggolin/NEM/err2.c deleted file mode 100755 index 18e77a54..00000000 --- a/ppanggolin/NEM/err2.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * program to compute permuted classification error in 2 cluster case. - * - * Mo Dang, oct 1997. - */ - -#include -#include - - -main(int argc, char *argv[]) -{ - int nbmax ; - int* clas1V ; - int* clas2V ; - int nbelts ; - int nbelts2 ; - int ielt ; - int nbdif ; - float percent ; - - int ReadIntVector( const char *fname, int* VP[], int nbmax ) ; - - if ( argc < 4 ) - { - fprintf( stderr, "Usage : %s file1 file2 nbmax\n" , argv[0] ) ; - fprintf( stderr, " computes the percentage of misclassification\n" ) ; - return 1 ; - } - - nbmax = atoi( argv[ 3 ] ) ; - nbelts = ReadIntVector( argv[1] , &clas1V , nbmax ) ; - if ( nbelts <= 0 ) - return 2 ; - - nbelts2 = ReadIntVector( argv[2], &clas2V, nbmax ) ; - if ( nbelts2 != nbelts ) - { - fprintf( stderr, "Error : %d elts in %s and %d elts in %s\n", - nbelts, argv[1], nbelts2, argv[2] ) ; - return 3 ; - } - - for ( ielt = 1, nbdif = 0 ; ielt <= nbelts ; ielt ++ ) - { - if ( clas1V[ ielt ] != clas2V[ ielt ] ) - nbdif ++ ; - } - - if ( nbdif > nbelts / 2 ) - nbdif = nbelts - nbdif ; - - percent = ( 100.0 * nbdif ) / nbelts ; - - fprintf( stdout , "Error = %3.1f %% (%d on %d)\n", percent , - nbdif , nbelts ) ; - - return 0 ; -} - - - - - -int ReadIntVector( const char *fname, int* VP[], int nbmax ) -{ - FILE* fid ; - int nbelts ; - - if ( ( fid = fopen( fname , "r" ) ) == NULL ) - { - fprintf( stderr , "Cannot open file %s\n" , fname ) ; - *VP = NULL ; - return 2 ; - } - - if( ( *VP = calloc( nbmax + 1 , sizeof( int ) ) ) == NULL ) - { - fprintf( stderr , "Not enough memory\n" ) ; - fclose( fid ) ; - return 2 ; - } - - for ( nbelts = 0 ; ( nbelts <= nbmax ) && (! feof( fid ) ) ; ) - { - int n ; - - if ( fscanf( fid , "%d", &n ) >= 1 ) - { - nbelts ++ ; - (*VP)[ nbelts ] = n ; - } - } - - if ( nbelts == 0 ) - { - free( *VP ) ; - *VP = NULL ; - } - - fclose( fid ) ; - - return nbelts ; -} diff --git a/ppanggolin/NEM/exemain.c b/ppanggolin/NEM/exemain.c deleted file mode 100755 index 37e787cd..00000000 --- a/ppanggolin/NEM/exemain.c +++ /dev/null @@ -1,32 +0,0 @@ -/*\ - - main.c - - A main() interface to compile a standalone program which is - executable from the operating system. - - Jan 1998 - - Van Mo DANG - Universite de Technologie de Compiegne - URA CNRS 817 - -Vers-mod Date Who Description - -1.05-a 25-JAN-1998 MD Create to make an interface to operating system -1.05-b 30-JAN-1998 MD Prototype of called mainfunc() in mainfunc.h -\*/ - - -#include "mainfunc.h" /* mainfunc() */ - -/* ------------------------------------------------------------------- */ -main( int argc, const char *argv[] ) -/*\ - Interface to a main routine. -\*/ -/* ------------------------------------------------------------------- */ -{ - return mainfunc( argc, argv ) ; -} -/* ~~~~~~~~~~~~~~~~~~~~~~~~ END OF FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/ppanggolin/NEM/exememo.c b/ppanggolin/NEM/genmemo.c similarity index 97% rename from ppanggolin/NEM/exememo.c rename to ppanggolin/NEM/genmemo.c index 7e166935..3f327bb8 100755 --- a/ppanggolin/NEM/exememo.c +++ b/ppanggolin/NEM/genmemo.c @@ -1,5 +1,5 @@ /*\ - exememo.c + genmemo.c Specific routines for operating system memory allocation @@ -17,7 +17,7 @@ #include /* calloc, free, size_t */ #include /* stderr */ - +#include "genmemo.h" /* ------------------------------------------------------------------- */ void* GenAlloc ( diff --git a/ppanggolin/NEM/geo2nei.c b/ppanggolin/NEM/geo2nei.c deleted file mode 100755 index 5df11e6c..00000000 --- a/ppanggolin/NEM/geo2nei.c +++ /dev/null @@ -1,787 +0,0 @@ -/*\ - - geo2nei.c - - This utility takes as input a set of geographic coordinates - and computes the neighborhood system induced by the distances - between the objects. - - November 1997 - - Mo Van Dang - Universite de Technologie de Compiegne - URA CNRS 817 - -\*/ - -#include /* FILE , printf ... */ -#include /* malloc, ... */ -#include "values.h" /* MAXFLOAT */ -#include /* sqrt */ - -#include "lib_io.h" /* AskFileToRead ... */ - -#define VERSION "1.00" - - -#define MAT( A , nl , nc , l , c ) ( ( A[ ( l * nc ) + c ] ) ) - - -#define TRUE 1 -#define FALSE 0 - -#define MAX_DIM 4 -#define LEN_DESC 500 - -#define EXPFAC 3.0 - -#define SEPAR_STR " \t" - -#ifndef MAXFLOAT - #ifdef FLT_MAX - #define MAXFLOAT FLT_MAX - #else - #define MAXFLOAT 3.40282347e+38F - #endif -#endif - - -typedef enum { - WEI_NONE, - WEI_CONST, - WEI_EXP, - WEI_NB -} -WeiModT ; - - -typedef struct -{ - int Nelts; /* number of elements */ - float AveSumWei ; /* ave sum of weights */ - float MinSumWei ; /* min sum of weights */ - float MaxSumWei ; /* max sum of weights */ - float AveDisNearest ; /* ave distance to 4th nearest neighbor */ - float MinDisNearest ; /* min distance to 4th nearest neighbor */ - float MaxDisNearest ; /* max distance to 4th nearest neighbor */ - float AveNbNei ; /* ave number of neighbors */ - int MinNbNei ; /* minimum number of neighbors */ - int MaxNbNei ; /* maximum number of neighbors */ -} -StatsT ; - - - -main( int argc , char *argv[] ) -{ - int sts = 0 ; /* status returned by the program */ - char namedat[ LEN_FILE + 1 ] ; /* input data file name */ - char namenei[ LEN_FILE + 1 ] ; /* output neighbors file name */ - char descnei[ LEN_DESC + 1 ] ; /* comment of neigbors file */ - int nd ; /* number of spatial variables */ - int d ; /* current spatial variable */ - int spacol[ MAX_DIM ] ; /* columns of spatial variables */ - int mincol , ncol ; /* input file : nb of columns */ - int npt ; /* input file : nb of lines */ - float* locM ; /* spatial locations : npt * nd */ - - int ranknei ; /* rank of nearest neighbor */ - float weifac ; /* factor -> average sum weights = 4 */ - float disthres ; /* pts neighbors if dis<=threshold */ - WeiModT weimod ; /* weight computation mode */ - - StatsT stats ; /* neighbor stats */ - - void PrintHelp( const char* CmdName ) ; - void PrintVersion( const char* CmdName ) ; - - int ComputeNeighbors - ( - const float* PtsM , - int Npt , - int Nc , - int RankNei , - float Dth, - WeiModT WeiMod , - float WeiFac , - const char* NameNei , - const char* Desc , - int DoSave , - StatsT* NeiStatsP - ) ; - - void DisplayStats - ( - int RankNei, /* I : rank of nearest neighbor */ - const StatsT* StatsP /* I : distances/neighbors statistics */ - ) ; - - - if ( argc > 1 ) - { - if ( strcmp( argv[ 1 ] , "-h" ) == 0 ) - { - PrintHelp( argv[ 0 ] ) ; - return 1 ; - } - else if ( strcmp( argv[ 1 ] , "-v" ) == 0 ) - { - PrintVersion( argv[ 0 ] ) ; - return 1 ; - } - else - { - printf( "Type %s -h to get help or -v to know current version\n" , - argv[ 0 ] ) ; - return 2 ; - } - } - - printf( "* * * Welcome to GEO2NEI program V%s * * *\n\n" , - VERSION ) ; - - /* Ask for all parameters : - input file name, number and columns of spatial variables ; - */ - if ( AskFileToRead( "input objects-variables", namedat ) != 0 ) - return 2 ; - if ( AskFileToWrite( "output neighborhood" , FALSE , namenei ) != 0 ) - return 2 ; - printf( "Enter comment in neighbors file : " ) ; - gets( descnei ) ; - - if ( AskInteger( "number of spatial coordinates" , 2 , 1 , MAX_DIM , - & nd ) != 0 ) - return 2 ; - - for ( d = 0 ; d < nd ; d ++ ) - { - char msg[ 120 ] ; - - sprintf( msg , "column of spatial coordinate %d" , d + 1 ) ; - if ( AskInteger( msg , d + 1 , 1 , 100 , & spacol[ d ] ) != 0 ) - return 2 ; - spacol[ d ] -- ; /* C-like indices start from 0 */ - } - - if ( AskInteger( "Average number of neighbors" , 4 , 1 , 20 , - & ranknei ) != 0 ) - return 2 ; - - if ( AskInteger( "Weight computation {0=>none, 1=>const 2=>exp[(-d/dmax)^2]}" , - WEI_NONE , WEI_NONE , WEI_NB-1 , (int*) & weimod ) != 0 ) - return 2 ; - -/* if ( AskFloat( "Distance threshold" , 1.00 , 0.01 , 100.00 , -/* & disthres ) != 0 ) -/* return 2 ; - */ - - printf( "Analyzing file %s ...\n" , namedat ) ; - switch( CountLinesColumns( namedat , SEPAR_STR , - &mincol , &ncol , &npt ) ) - { - case 0 : printf( "File %s : %d points, %d columns\n", - namedat, npt, ncol ) ; - break ; - case 1 : printf( "Error : '%s' unequal columns (%d to %d)\n" , - namedat , mincol , ncol ) ; - return 2 ; - default : - printf( "Error while analyzing file %s\n" , namedat ) ; - return 2 ; - } - - for ( d = 0 ; d < nd ; d ++ ) - { - if ( spacol[ d ] >= ncol ) - { - printf( "Error : spatial var. %d's column = %d > nb columns\n" , - d + 1 , spacol[ d ] + 1 ) ; - return 2 ; - } - } - - - /* Allocate and read spatial locations from file to memory - */ - if ( ( locM = malloc( npt * nd * sizeof( float ) ) ) == NULL ) - { - printf( "Error : out of memory for %d site locations\n" , npt ) ; - return 2 ; - } - - if ( ReadSelectedColumns( namedat , npt , ncol , nd , spacol , - locM ) != 0 ) - { - printf( "Error while reading spatial locations from file\n" ) ; - free( locM ) ; - return 2 ; - } - - /* Compute and save neighborhood system - */ - printf( "Computing neighborhood graph ...\n" ) ; - - /* Step 1 : compute distance stats to set distance threshold */ - disthres = 1.0 ; - weifac = 1.0 ; - if ( ComputeNeighbors( locM , npt , nd , ranknei , disthres , - WEI_NONE , weifac , namenei , descnei , FALSE , - &stats ) != -1 ) - { - /* Step 2 : compute neighborhood graph with non-normalized weights */ - disthres = stats.AveDisNearest * 1.1 ; - if ( ComputeNeighbors( locM , npt , nd , ranknei , disthres , - weimod , weifac , namenei , descnei , FALSE , - &stats ) != -1 ) - { - /* Step 3 : save neighborhood graph with normalized weights */ - weifac = 4.0 / stats.MaxSumWei ; - printf( "weifac = %g\n", weifac ) ; - if ( ComputeNeighbors( locM , npt , nd , ranknei , disthres , - weimod , weifac , namenei , descnei , TRUE , - &stats ) != -1 ) - DisplayStats( ranknei, &stats ) ; - else - printf( "Error while computing neighborhood graph 2\n" ) ; - } - else - printf( "Error while computing neighborhood graph 1\n" ) ; - - } - else - printf( "Error while computing distance statistics\n" ) ; - - - /* Free allocated memory */ - free( locM ) ; - - return sts ; - -} /* main() */ - - - - -/* ------------------------------------------------------------------- */ -int ComputeNeighbors - ( - const float* PtsM , - int Npt , - int Nd , - int RankNei , - float Dth , - WeiModT WeiMod , - float WeiFac , - const char* NameNei , - const char* Desc , - int DoSave , - StatsT* StatsP - ) -/* ------------------------------------------------------------------- */ -{ - FILE* fnei ; /* File to write into */ - float sqrDth ; /* Squared distance threshold */ - - float* sqrDisV ; /* [Npt] Current point's distance to other points */ - float* weiV ; /* [Npt] Current point's neighbors weights > 0.0 */ - int* neiV ; /* [Npt] Current point's neighbors indices 0..Npt-1 */ - - int pt ; /* Index of current point 0..Npt-1 */ - int ok ; /* FALSE if problem in writing file */ - - void StartStats - ( - int Npt , /* I : number of points */ - StatsT* StatsP /* O : distances/neighbors statistics */ - ) ; - - void CompuSqrDisV - ( - int Pt , /* I : index of current point 0..Npt-1 */ - int RankNei, /* I : neighbor rank to compute distance */ - const float* PtsM , /* I : [Npt*Nd] matrix of point coordinates */ - int Npt , /* I : number of points */ - int Nd , /* I : number of coordinates */ - float* SqrDisV , /* O : [Npt] distances to other points */ - float* SqrDnearP /* O : distance to nearest point */ - ) ; - - void SqrDisVToNeiV - ( - int Pt , /* I : index of current point 0..Npt-1 */ - float SqrDth , /* I : squared distance threshold */ - const float* SqrDisV , /* I : [Npt] distances to other points */ - int Npt , /* I : number of points */ - WeiModT WeiMod , /* I : weight computation mode */ - float WeiFac , /* I : weight normalizing factor */ - int* NbNeiP , /* O : number of neighbors 0..Npt-1 */ - int* NeiV , /* O : [Npt] neighbors indices 0..Npt-1 */ - float* WeiV , /* O : [Npt] neighbors weights > 0.0 */ - float* SumWeiP /* O : sum of weights > 0.0 */ - ) ; - - void UpdateStats - ( - int Pt , /* I : index of current point 0..Npt-1 */ - float SqrDnear, /* I : distance to nearest point */ - int NbNei , /* I : number of neighbors 0..Npt-1 */ - float SumWei , /* I : sum of neighbor weights */ - StatsT* StatsP /* I/O : distances/neighbors statistics */ - ) ; - - int SaveNeiV - ( - FILE* Fnei , /* I/O : file to write into */ - int Pt , /* I : index of current point 0..Npt-1 */ - int NbNei , /* I : number of neighbors 0..Npt-1 */ - const int* NeiV /* I : [Npt] neighbors indices 0..Npt-1 */ - ) ; - - int SaveWeiV - ( - FILE* Fnei , /* I/O : file to write into */ - int NbNei , /* I : number of neighbors 0..Npt-1 */ - const float* WeiV /* I : [Npt] neighbors weights > 0.0 */ - ) ; - - void CloseStats - ( - StatsT* StatsP /* I/O : distances/neighbors statistics */ - ) ; - - - - /* Convert parameters to squared distances */ - sqrDth = Dth * Dth ; - - /* If save to file requested, create file and write header */ - if ( DoSave ) - { - if ( ( fnei = fopen( NameNei , "w" ) ) == NULL ) - { - printf( "Error : cannot create file %s\n", NameNei ) ; - return -1 ; - } - - fprintf( fnei , "# %s\n" , Desc ) ; - if ( WeiMod == WEI_NONE ) - fprintf( fnei , "0\n" ) ; - else - fprintf( fnei , "1\n" ) ; - } - - /* Allocate memory for local computations */ - sqrDisV = malloc( Npt * sizeof( float ) ) ; - weiV = malloc( Npt * sizeof( float ) ) ; - neiV = malloc( Npt * sizeof( int ) ) ; - if ( ( sqrDisV == NULL ) || ( weiV == NULL ) || ( neiV == NULL ) ) - { - printf( "Could not allocate distance/weight/neigbor vectors [%d]\n" , - Npt ) ; - if ( sqrDisV != NULL ) free( sqrDisV ) ; - if ( weiV != NULL ) free( weiV ) ; - - return -1 ; - } - - - /* For each point */ - for ( pt = 0 , - ok = TRUE , - StartStats( Npt , StatsP ) ; - ( pt < Npt ) && ok ; - pt ++ ) - { - float sqrdisNearest ; /* Distance to nearest point */ - int nbnei ; /* Number of neighbors */ - float sumwei ; /* Sum of neighbor weights */ - - /* Compute its distance to other points */ - CompuSqrDisV( pt , RankNei, PtsM , Npt , Nd , - sqrDisV , &sqrdisNearest ) ; - - /* Threshold the computed distances to get neighbors and weights */ - SqrDisVToNeiV( pt , sqrDth , sqrDisV , Npt , WeiMod , WeiFac , - &nbnei , neiV , weiV , &sumwei ) ; - - /* printf( "sumwei %d = %g\n" , pt , sumwei ) ; */ - - /* Update distance/neighbor statistics */ - UpdateStats( pt , sqrdisNearest , nbnei , sumwei , StatsP ) ; - - /* Eventually save neighbors and weights to file */ - if ( DoSave ) - { - if ( SaveNeiV( fnei , pt , nbnei , neiV ) != 0 ) - ok = FALSE ; - else - if ( WeiMod != WEI_NONE ) - if ( SaveWeiV( fnei , nbnei , weiV ) != 0 ) - ok = FALSE ; - fprintf( fnei , "\n" ) ; - } - } - CloseStats( StatsP ) ; - - - /* Free memory used for local computations */ - free( sqrDisV ) ; - free( neiV ) ; - free( weiV ) ; - - /* If save to file requested, close file */ - if ( DoSave ) - { - fclose( fnei ) ; - } - - if ( ok ) - return 0 ; - else - return -1 ; - -} /* end of ComputeNeighbors() */ - - - -/* ------------------------------------------------------------------- */ -void StartStats - ( - int Npt , /* I : number of points */ - StatsT* StatsP /* O : distances/neighbors statistics */ - ) -/* ------------------------------------------------------------------- */ -{ - StatsP->Nelts = 0 ; - - StatsP->AveSumWei = 0.0 ; - StatsP->MinSumWei = MAXFLOAT ; - StatsP->MaxSumWei = 0.0 ; - - StatsP->AveDisNearest = 0.0 ; - StatsP->MinDisNearest = MAXFLOAT ; - StatsP->MaxDisNearest = MINFLOAT ; - - StatsP->AveNbNei = 0.0 ; - StatsP->MinNbNei = Npt ; - StatsP->MaxNbNei = 0 ; -} - - -/* ------------------------------------------------------------------- */ -void UpdateStats - ( - int Pt , /* I : index of current point 0..Npt-1 */ - float SqrDnear, /* I : distance to nearest point */ - int NbNei , /* I : number of neighbors 0..Npt-1 */ - float SumWei , /* I : sum of neighbor weights */ - StatsT* StatsP /* I/O : distances/neighbors statistics */ - ) -/* ------------------------------------------------------------------- */ -{ - - StatsP->Nelts ++ ; - - - StatsP->AveSumWei += SumWei ; - - if ( SumWei < StatsP->MinSumWei ) - StatsP->MinSumWei = SumWei ; - - if ( SumWei > StatsP->MaxSumWei ) - StatsP->MaxSumWei = SumWei ; - - - StatsP->AveDisNearest += sqrt( SqrDnear ) ; - - if ( SqrDnear < StatsP->MinDisNearest ) - StatsP->MinDisNearest = SqrDnear ; - - if ( SqrDnear > StatsP->MaxDisNearest ) - StatsP->MaxDisNearest = SqrDnear ; - - - StatsP->AveNbNei += NbNei ; - - if ( NbNei < StatsP->MinNbNei ) - StatsP->MinNbNei = NbNei ; - - if ( NbNei > StatsP->MaxNbNei ) - StatsP->MaxNbNei = NbNei ; - -} - - -/* ------------------------------------------------------------------- */ -void CloseStats - ( - StatsT* StatsP /* I/O : distances/neighbors statistics */ - ) -/* ------------------------------------------------------------------- */ -{ - if ( StatsP->MinDisNearest >= 0 ) - StatsP->MinDisNearest = sqrt( StatsP->MinDisNearest ) ; - - if ( StatsP->MaxDisNearest >= 0 ) - StatsP->MaxDisNearest = sqrt( StatsP->MaxDisNearest ) ; - - if ( StatsP->Nelts > 0 ) - { - StatsP->AveSumWei /= StatsP->Nelts ; - StatsP->AveDisNearest /= StatsP->Nelts ; - StatsP->AveNbNei /= StatsP->Nelts ; - } -} - - -/* ------------------------------------------------------------------- */ -void DisplayStats - ( - int RankNei, /* I : rank of nearest neighbor */ - const StatsT* StatsP /* I : distances/neighbors statistics */ - ) -/* ------------------------------------------------------------------- */ -{ - printf( "Statistics (ave, min, max) : \n" ) ; - printf( " Distance to %dth nearest site : %8.2f (%8.2f to %8.2f)\n" , - RankNei, - StatsP->AveDisNearest, - StatsP->MinDisNearest , StatsP->MaxDisNearest ); - printf( " Number of neighbors : %8.2f (%8d to %8d)\n" , - StatsP->AveNbNei , - StatsP->MinNbNei , StatsP->MaxNbNei ); - printf( " Sum of neighbor weights : %8.2f (%8.2f to %8.2f)\n" , - StatsP->AveSumWei, - StatsP->MinSumWei , StatsP->MaxSumWei ); -} - -/* ------------------------------------------------------------------- */ -static int floatcompare(const void *x, const void *y) -/* ------------------------------------------------------------------- */ -{ - const float* xx = x; - const float* yy = y; - - if (*xx > *yy) - return (1); - if (*xx < *yy) - return (-1); - return (0); -} - -/* ------------------------------------------------------------------- */ -/* Computes the distances from a given point to other points - */ -void CompuSqrDisV - ( - int Pt , /* I : index of current point 0..Npt-1 */ - int RankNei, /* I : neighbor rank to compute distance */ - const float* PtsM , /* I : [Npt*Nd] matrix of point coordinates */ - int Npt , /* I : number of points */ - int Nd , /* I : number of coordinates */ - float* SqrDisV , /* O : [Npt] distances to other points */ - float* SqrDnearP /* O : distance to RankNei nearest point */ - ) -/* ------------------------------------------------------------------- */ -{ - int j ; - float dnear ; - - for ( j = 0 , dnear = MAXFLOAT ; j < Npt ; j ++ ) - { - if ( j != Pt ) - { - int d ; - float sqrdis ; - - for ( d = 0 , sqrdis = 0.0 ; d < Nd ; d ++ ) - { - float cpt = MAT( PtsM , Npt , Nd , Pt , d ) ; - float cj = MAT( PtsM , Npt , Nd , j , d ) ; - float dif = cpt - cj ; - - sqrdis = sqrdis + dif * dif ; - } - - /* +++ */ if ( sqrdis == 0.0 ) - printf( "*** Warning : Points %d and %d have same location\n" , - Pt+1 , j+1 ) ; - - SqrDisV[ j ] = sqrdis ; - if ( sqrdis < dnear ) - dnear = sqrdis ; - } - else - SqrDisV[ j ] = 0.0 ; - } - - /* Compute distance to RankNei'th nearest location */ - { - float* sortdis_1n = calloc( Npt , sizeof( float ) ) ; - - if ( sortdis_1n == NULL ) - { - (*SqrDnearP) = dnear ; - return ; - } - - /* Sort the distances to other locations - */ - memcpy( sortdis_1n , SqrDisV , Npt * sizeof( float ) ) ; - - qsort( sortdis_1n , Npt, sizeof( float ), floatcompare ) ; - - (*SqrDnearP) = sortdis_1n[ RankNei - 1 ] ; - - free( sortdis_1n ) ; - } -} - - -/* ------------------------------------------------------------------- */ -/* Thresholds the computed distances to get neighbors and weights */ -void SqrDisVToNeiV - ( - int Pt , /* I : index of current point 0..Npt-1 */ - float SqrDth , /* I : squared distance threshold */ - const float* SqrDisV , /* I : [Npt] distances to other points */ - int Npt , /* I : number of points */ - WeiModT WeiMod , /* I : weight computation mode */ - float WeiFac , /* I : weight normalizing factor */ - int* NbNeiP , /* O : number of neighbors 0..Npt-1 */ - int* NeiV , /* O : [Npt] neighbors indices 0..Npt-1 */ - float* WeiV , /* O : [Npt] neighbors weights > 0.0 */ - float* SumWeiP /* O : sum of weights > 0.0 */ - ) -/* ------------------------------------------------------------------- */ -{ - int j ; - - for ( j = 0 , - (*NbNeiP) = 0, - (*SumWeiP) = 0.0 ; - j < Npt ; - j ++ ) - { - if ( j != Pt ) - { - if ( SqrDisV[ j ] <= SqrDth ) - { - NeiV[ (*NbNeiP) ] = j ; - - switch( WeiMod ) - { - case WEI_CONST: - WeiV[ (*NbNeiP) ] = 1.0 ; - break ; - - case WEI_EXP: - WeiV[ (*NbNeiP) ] = exp( - EXPFAC * - SqrDisV[ j ] / SqrDth ) ; - break ; - - default: - WeiV[ (*NbNeiP) ] = 1.0 ; - } - WeiV[ (*NbNeiP) ] *= WeiFac ; - - (*SumWeiP) += WeiV[ (*NbNeiP) ] ; - - (*NbNeiP) ++ ; - } - } - } -} - - - -/* ------------------------------------------------------------------- */ -int SaveNeiV - ( - FILE* Fnei , /* I/O : file to write into */ - int Pt , /* I : index of current point 0..Npt-1 */ - int NbNei , /* I : number of neighbors 0..Npt-1 */ - const int* NeiV /* I : [Npt] neighbors indices 0..Npt-1 */ - ) -/* ------------------------------------------------------------------- */ -{ - int nei ; - int ok ; - - fprintf( Fnei , "%4d %3d " , Pt + 1 , NbNei ) ; - for ( nei = 0 , ok = TRUE ; ( nei < NbNei ) && ok ; nei ++ ) - { - ok = ( fprintf( Fnei , "%4d " , NeiV[ nei ] + 1 ) > 0 ) ; - } - - return ( ok ? 0 : -1 ) ; -} - - - -int SaveWeiV - ( - FILE* Fnei , /* I/O : file to write into */ - int NbNei , /* I : number of neighbors 0..Npt-1 */ - const float* WeiV /* I : [Npt] neighbors weights > 0.0 */ - ) -{ - int nei ; - int ok ; - - for ( nei = 0 , ok = TRUE ; ( nei < NbNei ) && ok ; nei ++ ) - { - ok = ( fprintf( Fnei , " %4.2f" , WeiV[ nei ] ) > 0 ) ; - } - - return ( ok ? 0 : -1 ) ; -} - - - -void PrintHelp( const char* CmdName ) -{ - printf( "\n" ) ; - printf( "This program computes a neighborhood graph given a set of \n" ) ; - printf( "spatial coordinates. It saves the resulting graph in a \n" ) ; - printf( "neighborhood file which may be used as input to the \n" ) ; - printf( "program nem_exe. It uses a simple thresholding of the \n" ) ; - printf( "euclidean distances between the objects.\n" ) ; - printf( "\n" ) ; - printf( "Before running %s, the spatial coordinates should be given in \n" , - CmdName ) ; - printf( "an ASCII file, 1 line/object, 1 column/spatial coordinate.\n" ) ; - printf( "Example (spatial coordinates in columns 2 and 3 of file) : \n" ) ; - printf( " x 15 50 x x => 1st object is at position x = 15 y = 50\n" ) ; - printf( " x 30 20 x x => 2nd object is at position x = 30 y = 20\n" ) ; - printf( "The elements on a line should be separated by spaces or tabs\n" ) ; - printf( "\n" ) ; - printf( "--- Press ENTER for more ---\n" ) ; - getchar( ) ; - printf( "The program will prompt you for :\n" ) ; - printf( "1 - The name of the input spatial coordinates file\n" ) ; - printf( "2 - The name of the output neighborhood file\n" ) ; - printf( "3 - How many spatial coordinates and their column numbers\n" ) ; - printf( "4 - The desired average number of neighbors of an object ;\n" ) ; - printf( " this parameter is used to compute the distance threshold\n" ) ; - printf( "5 - How to calculate the weights : no weigths or exponential\n" ) ; - printf( " exponential means w_ij = A * exp - 3 (d_ij / d_th)^2\n" ) ; - printf( " i.e. weights decreasing as exp (- squared distance).\n" ) ; - printf( " Constant A is computed to have max_i( sum_j w_ij ) = 4,\n" ) ; - printf( " as in 4 nearest neighbor unweighted graphs\n" ) ; - printf( "\n" ) ; -} - - -void PrintVersion( const char* CmdName ) -{ - printf( "\n" ) ; - printf( "Version 1.00 (14-NOV-1997)\n" ) ; - printf( "==========================\n" ) ; - printf( "14-NOV-1997\n" ) ; - printf( "First complete version. \n" ) ; - printf( "Added help, computation of distance threshold and weights.\n" ) ; - printf( "\n" ) ; -} diff --git a/ppanggolin/NEM/mainfunc.h b/ppanggolin/NEM/mainfunc.h deleted file mode 100755 index d17f50b4..00000000 --- a/ppanggolin/NEM/mainfunc.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef MAINFUNC_H -#define MAINFUNC_H - -/* - * mainfunc.h - * - * Prototype of main function called either by mexFunction() or main() - * - */ - -int mainfunc( int argc, const char** argv ) ; - -#endif diff --git a/ppanggolin/NEM/makefile b/ppanggolin/NEM/makefile deleted file mode 100755 index 0861f215..00000000 --- a/ppanggolin/NEM/makefile +++ /dev/null @@ -1,258 +0,0 @@ -# -# --- Main groups of targets to be updated --- -# - -# V1.04-a 04-10-1997 MD add lint -# V1.04-b 18-11-1997 MD replace cc with gcc, add -lemu option -# V1.04-c 11-01-1998 MD archive name as variable -# V1.05-a 25-01-1998 MD add exemain.c -> nem_exe -# V1.05-b 25-01-1998 MD add mexmain.c and mex target -> nem_exe.mexsol -# V1.05-c 26-01-1998 MD add exememo.c -> nem_exe and mexmemo.c -> .mexsol -# V1.06-a 17-06-1998 MD change nem_noi -> nem_mod -# V1.06-b 23-06-1998 MD flag -Wall -# V1.06-c 23-06-1998 MD add target t_nem_arg -# V1.06-d 30-06-1998 MD add target t_nem_mod -# V1.07-a 29-02-1999 MD archive name : new version - -CFLAGS = -Wall - -# Flags for MS-DOS compilation using DJGPP's gcc -#CFLAGS = -lemu -Wall - -# Select C compiler here -CC = gcc -#CC = cc - -# Warning messages - - -# Name of uncompressed archive file to create -ARC = nem107.tar - -# Optimized application executables (default make) -exe : txt2hlp nem_exe geo2nei randord err2 tcpu - -# Matlab executable -mex : nem_exe.mexsol - -# Debuggable executables -dbg : g_nem_exe g_geo2nei g_randord - -# Archive -arc : $(ARC).Z - -# Everything -all : remobj mex exe dbg arc - -# Test version of nem_exe -test : nem_tmp - -# Tight syntax check -check : - lint nem_exe.c nem_arg.c nem_alg.c nem_nei.c \ - nem_mod.c nem_rnd.c nem_ver.c nem_hlp.c \ - lib_io.c exemain.c exememo.c - lint err2.c - lint tcpu.c - -# Remove all object files -remobj : - \rm *.o - -# -# --- Single targets --- -# - -# Archive commands to update source file archiving -$(ARC).Z : nem_exe.c nem_arg.c nem_alg.c nem_nei.c \ - nem_mod.c nem_rnd.c nem_ver.c nem_hlp.c \ - nem_typ.h nem_arg.h nem_alg.h nem_nei.h \ - nem_mod.h nem_rnd.h nem_ver.h nem_hlp.h \ - lib_io.c lib_io.h genmemo.h exemain.c exememo.c \ - mexmain.c mexmemo.c mainfunc.h \ - geo2nei.c randord.c \ - err2.c tcpu.c txt2hlp.c \ - simimg.str simimg.dat simimg.nei simimg.cr \ - simimg.cf simimg.mf \ - makefile - tar cvf $(ARC) nem_*.[ch] lib_*.[ch] exe*.c mex*.c gen*h \ - err2.c geo2nei.c randord.c txt2hlp.c tcpu.c mainfunc.h \ - simimg.str simimg.dat simimg.nei simimg.cr simimg.cf simimg.mf \ - nem_user.txt makefile - gzip -vf $(ARC) - \cp -p $(ARC).gz /home_f/mdang/public_html/Progs/$(ARC).gz - - -# Linkage commands to update the executables -nem_exe.mexsol : nem_exe.o nem_arg.o nem_alg.o nem_nei.o nem_mod.o nem_rnd.o \ - nem_ver.o nem_hlp.o lib_io.o mexmain.c mexmemo.c genmemo.h - cmex nem_exe.o nem_arg.o nem_alg.o nem_nei.o nem_mod.o nem_rnd.o \ - nem_ver.o nem_hlp.o lib_io.o mexmain.c mexmemo.c \ - -o nem_exe -lm -O - -nem_tmp : nem_exe.o nem_arg.o nem_alg.o nem_nei.o nem_mod.o nem_rnd.o \ - nem_ver.o nem_hlp.o lib_io.o exemain.o exememo.o - $(CC) nem_exe.o nem_arg.o nem_alg.o nem_nei.o nem_mod.o nem_rnd.o \ - nem_ver.o nem_hlp.o lib_io.o exemain.o exememo.o \ - -o nem_tmp -lm -O $(CFLAGS) - -nem_exe : nem_exe.o nem_arg.o nem_alg.o nem_nei.o nem_mod.o nem_rnd.o \ - nem_ver.o nem_hlp.o lib_io.o exemain.o exememo.o - $(CC) nem_exe.o nem_arg.o nem_alg.o nem_nei.o nem_mod.o nem_rnd.o \ - nem_ver.o nem_hlp.o lib_io.o exemain.o exememo.o \ - -o nem_exe -lm -O $(CFLAGS) - -g_nem_exe : g_nem_exe.o g_nem_arg.o g_nem_alg.o g_nem_nei.o \ - g_nem_mod.o g_nem_rnd.o g_nem_ver.o g_nem_hlp.o g_lib_io.o \ - g_exemain.o g_exememo.o - $(CC) g_nem_exe.o g_nem_arg.o g_nem_alg.o g_nem_nei.o \ - g_nem_mod.o g_nem_rnd.o g_nem_ver.o g_nem_hlp.o g_lib_io.o \ - g_exemain.o g_exememo.o \ - -o g_nem_exe -lm -g $(CFLAGS) - - -geo2nei : geo2nei.o lib_io.o - $(CC) geo2nei.o lib_io.o \ - -o geo2nei -lm -O $(CFLAGS) - -g_geo2nei : g_geo2nei.o g_lib_io.o - $(CC) g_geo2nei.o g_lib_io.o \ - -o g_geo2nei -lm -O $(CFLAGS) - -randord : randord.o nem_rnd.o - $(CC) randord.o nem_rnd.o \ - -o randord -lm -O $(CFLAGS) - -g_randord : g_randord.o g_nem_rnd.o - $(CC) g_randord.o g_nem_rnd.o \ - -o g_randord -lm -g $(CFLAGS) - -tcpu : tcpu.c - $(CC) tcpu.c -o tcpu -lm -O $(CFLAGS) - - -# Linkage commands to update the test executables - -#V1.06-c -t_nem_arg : g_nem_arg.o g_lib_io.o g_nem_hlp.o g_exememo.o g_nem_ver.o - $(CC) g_nem_arg.o g_lib_io.o g_nem_hlp.o g_exememo.o g_nem_ver.o \ - -o $@ -lm -g $(CFLAGS) - -#V1.06-d -t_nem_mod.out : nem_mod.c t_nem_mod.c t_nem_mod.sh - $(CC) g_exememo.o t_nem_mod.c -o t_nem_mod -lm -g $(CFLAGS) - @t_nem_mod.sh > tmp.out - @echo "\ndiff tmp.out t_nem_mod.out :\n" - if ( diff tmp.out t_nem_mod.out ) ; \ - then \ - echo "test of nem_mod.c OK" ; touch t_nem_mod.out ; \ - else \ - echo "\07\nWarning \07: output of test of nem_mod.c changed" ; \ -# echo "Change t_nem_mod.out ?" ; ; \ -# if "$a" = "y"; then \mv tmp.out t_nem_mod.out; fi ; \ - fi - @\rm tmp.out - @\rm t_nem_mod - -t_nem_mod : nem_mod.c t_nem_mod.c g_exememo.o - $(CC) g_exememo.o t_nem_mod.c \ - -o $@ -lm -g $(CFLAGS) -# -# --- Secondary targets (object files) --- -# - -# Compilation commands to update the object files -nem_exe.o : nem_exe.c nem_typ.h nem_arg.h nem_alg.h nem_rnd.h lib_io.h - $(CC) -c nem_exe.c -O $(CFLAGS) - -g_nem_exe.o : nem_exe.c nem_typ.h nem_arg.h nem_alg.h nem_rnd.h lib_io.h - $(CC) -c nem_exe.c -g $(CFLAGS) -o g_nem_exe.o - - -nem_arg.o : nem_arg.c nem_typ.h nem_arg.h - $(CC) -c nem_arg.c -O $(CFLAGS) - -g_nem_arg.o : nem_arg.c nem_typ.h nem_arg.h - $(CC) -c nem_arg.c -g $(CFLAGS) -o g_nem_arg.o - - -nem_alg.o : nem_alg.c nem_typ.h nem_alg.h nem_nei.h nem_mod.h nem_rnd.h - $(CC) -c nem_alg.c -O $(CFLAGS) - -g_nem_alg.o : nem_alg.c nem_typ.h nem_alg.h nem_nei.h nem_mod.h nem_rnd.h - $(CC) -c nem_alg.c -g $(CFLAGS) -o g_nem_alg.o - - -nem_nei.o : nem_nei.c nem_typ.h nem_nei.h - $(CC) -c nem_nei.c -O $(CFLAGS) - -g_nem_nei.o : nem_nei.c nem_typ.h nem_nei.h - $(CC) -c nem_nei.c -g $(CFLAGS) -o g_nem_nei.o - - -nem_mod.o : nem_mod.c nem_typ.h nem_mod.h - $(CC) -c nem_mod.c -O $(CFLAGS) - -g_nem_mod.o : nem_mod.c nem_typ.h nem_mod.h - $(CC) -c nem_mod.c -g $(CFLAGS) -o g_nem_mod.o - - -nem_hlp.o : nem_hlp.c nem_hlp.h - $(CC) -c nem_hlp.c -O $(CFLAGS) - -g_nem_hlp.o : nem_hlp.c nem_hlp.h - $(CC) -c nem_hlp.c -g $(CFLAGS) -o g_nem_hlp.o - - -nem_ver.o : nem_ver.c nem_typ.h nem_ver.h - $(CC) -c nem_ver.c -O $(CFLAGS) - -g_nem_ver.o : nem_ver.c nem_typ.h nem_ver.h - $(CC) -c nem_ver.c -g $(CFLAGS) -o g_nem_ver.o - - -nem_rnd.o : nem_rnd.c nem_rnd.h - $(CC) -c nem_rnd.c -O $(CFLAGS) - -g_nem_rnd.o : nem_rnd.c nem_rnd.h - $(CC) -c nem_rnd.c -g $(CFLAGS) -o g_nem_rnd.o - - -lib_io.o : lib_io.c lib_io.h - $(CC) -c lib_io.c -O $(CFLAGS) - -g_lib_io.o : lib_io.c lib_io.h - $(CC) -c lib_io.c -g $(CFLAGS) -o g_lib_io.o - -exemain.o : exemain.c - $(CC) -c exemain.c -O $(CFLAGS) - -g_exemain.o : exemain.c - $(CC) -c exemain.c -g $(CFLAGS) -o g_exemain.o - -exememo.o : exememo.c genmemo.h - $(CC) -c exememo.c -O $(CFLAGS) - -g_exememo.o : exememo.c genmemo.h - $(CC) -c exememo.c -g $(CFLAGS) -o g_exememo.o - -geo2nei.o : geo2nei.c lib_io.h - $(CC) -c geo2nei.c -O $(CFLAGS) - -g_geo2nei.o : geo2nei.c lib_io.h - $(CC) -c geo2nei.c -g $(CFLAGS) -o g_geo2nei.o - - -randord.o : randord.c nem_rnd.h - $(CC) -c randord.c -O $(CFLAGS) - -g_randord.o : randord.c nem_rnd.h - $(CC) -c randord.c -g $(CFLAGS) -o g_randord.o - -# -# --- Auxiliary targets (automated source files) --- -# - -nem_hlp.c : nem_user.txt - ./txt2hlp nem_user.txt nem_hlp y \ - "Project NEM : display of long help" > /dev/null diff --git a/ppanggolin/NEM/nem.pyx b/ppanggolin/NEM/nem.pyx new file mode 100755 index 00000000..a295ef76 --- /dev/null +++ b/ppanggolin/NEM/nem.pyx @@ -0,0 +1,14 @@ +cdef extern from "nem_exe.h": + cpdef int nem(const char* Fname, + const int nk, + const char* algo, + const float beta, + const char* convergence, + const float convergence_th, + const char* format, + const int it_max, + const int dolog, + const char* model_family, + const char* proportion, + const char* dispersion, + const int init_mode); diff --git a/ppanggolin/NEM/nem_alg.c b/ppanggolin/NEM/nem_alg.c index 981bc1d2..1863b7de 100755 --- a/ppanggolin/NEM/nem_alg.c +++ b/ppanggolin/NEM/nem_alg.c @@ -62,7 +62,6 @@ Vers-mod Date Who Description \*/ #include "nem_typ.h" /* DataT, ... */ -#include "nem_arg.h" /* CritStrVC */ #include "nem_nei.h" /* FuncNeighNone, ... */ #include "nem_mod.h" /* EstimPara, ... */ #include "nem_rnd.h" /* RandomInteger */ @@ -576,7 +575,7 @@ int ClassifyByNem /*V1.04-a*/ break ; default: - fprintf( stderr , "Error : unkwnown beta estimation mode %d\n", + fprintf( out_stderr , "Error : unkwnown beta estimation mode %d\n", StatModelP->Spec.BetaModel ) ; sts = STS_E_FUNCARG ; } @@ -808,13 +807,13 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ Lfound = FALSE ; /* Initialize values for likelihood heuristic */ LlossThres= NemParaP->BtaHeuLLoss * DataP->NbPts; - fprintf( stderr, "* * Starting heuristic * *\n" ) ; - fprintf( stderr, " Parameters : " ) ; + fprintf( out_stderr, "* * Starting heuristic * *\n" ) ; + fprintf( out_stderr, " Parameters : " ) ; if ( StatModelP->Spec.BetaModel == BETA_HEUD ) - fprintf( stderr, "Drop < %3.1f or (Dmax - D) < %3.1f (Dmax - Dmin)\n" , + fprintf( out_stderr, "Drop < %3.1f or (Dmax - D) < %3.1f (Dmax - Dmin)\n" , DdropThres, NemParaP->BtaHeuDLoss ) ; else - fprintf( stderr, "L < Lmax - %3.1f \n" , LlossThres ) ; + fprintf( out_stderr, "L < Lmax - %3.1f \n" , LlossThres ) ; for ( btatest = 0.0, nbta = 0, stop = FALSE ; ( btatest <= NemParaP->BtaHeuMax ) && ( ! stop ) ; @@ -822,7 +821,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ { StatusET sts ; - fprintf( stderr, "\n * * Testing beta = %5.2f * * \n" , btatest ) ; + fprintf( out_stderr, "\n * * Testing beta = %5.2f * * \n" , btatest ) ; StatModelP->Para.Beta = btatest ; @@ -856,7 +855,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ if ( nbta >= 3 ) { - fprintf( stderr, " * Drop : %5.1f (threshold %5.1f) *\n", + fprintf( out_stderr, " * Drop : %5.1f (threshold %5.1f) *\n", ( thisSlope - prevSlope ) , DdropThres ) ; if ( (! Ddrop) && (! Dincreas) ) { @@ -865,7 +864,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ Ddrop = TRUE ; if ( ! NemParaP->Debug ) stop = TRUE ; - fprintf( stderr, " * ---> Drop detected *\n" ) ; + fprintf( out_stderr, " * ---> Drop detected *\n" ) ; /* btaEst = btaV[ nbta - 2 ] ; V1.06-i*/ btaEst = btaV[ nbta - 1 ] ; @@ -892,7 +891,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ if ( nbta < 2 ) /* 1st beta */ { Lmax = CriterP->L ; - fprintf( stderr, " * * L threshold : %3.1f * * \n" , + fprintf( out_stderr, " * * L threshold : %3.1f * * \n" , Lmax - LlossThres ) ; memcpy( clasbestM, ClassifM, npt * nk * sizeof( float ) ) ; } @@ -901,7 +900,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ if ( CriterP->L > Lmax ) { Lmax = CriterP->L ; - fprintf( stderr, " * * L threshold : %3.1f * * \n" , + fprintf( out_stderr, " * * L threshold : %3.1f * * \n" , Lmax - LlossThres ) ; } @@ -911,7 +910,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ Lfound = TRUE ; if ( ! NemParaP->Debug ) stop = TRUE ; - fprintf( stderr, " * ---> L loss detected *\n" ) ; + fprintf( out_stderr, " * ---> L loss detected *\n" ) ; /* btaEst = btaV[ nbta - 2 ] ; V1.06-i*/ btaEst = btaV[ nbta - 1 ] ; } @@ -952,7 +951,7 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ btaEst = btaV[ ibta - 2 ] ; else { - fprintf( stderr , "Warning : heuristic failed to detect beta\n" ) ; + fprintf( out_stderr , "Warning : heuristic failed to detect beta\n" ) ; btaEst = 0.0 ; } @@ -970,15 +969,15 @@ static int ClassifyByNemHeuBeta /*V1.04-a*/ { /* btaEst = btaV[ nbta - 1 ] ; V1.06-i*/ btaEst = btaV[ nbta ] ; - fprintf( stderr, " * L loss not detected *\n" ) ; + fprintf( out_stderr, " * L loss not detected *\n" ) ; } if ( fcri != NULL ) fclose( fcri ) ; - fprintf( stderr , "\n * * * Estimated beta : %3.2f * * *\n" , btaEst ) ; + fprintf( out_stderr , "\n * * * Estimated beta : %3.2f * * *\n" , btaEst ) ; if ( StatModelP->Spec.BetaModel == BETA_HEUD ) - fprintf( stderr , " * * * Using %s * * *\n\n" , + fprintf( out_stderr , " * * * Using %s * * *\n\n" , Ddrop ? "drop detection" : "loss thresholding" ) ; @@ -1031,7 +1030,7 @@ static int ClassifyByNemOneBeta /*V1.04-a*/ } #ifdef __TURBOC__ - fprintf( stderr, "\n Remaining memory after allocating : %lu bytes\n", + fprintf( out_stderr, "\n Remaining memory after allocating : %lu bytes\n", (unsigned long) coreleft() ); #endif @@ -1044,7 +1043,7 @@ static int ClassifyByNemOneBeta /*V1.04-a*/ ( ( working.Neighs.NeighsV == NULL ) && ( SpatialP->MaxNeighs > 0 ) ) ) { - fprintf( stderr, "Could not allocate NEM working variables\n" ); + fprintf( out_stderr, "Could not allocate NEM working variables\n" ); return STS_E_MEMORY ; } @@ -1059,7 +1058,7 @@ static int ClassifyByNemOneBeta /*V1.04-a*/ switch( NemParaP->InitMode ) { case INIT_SORT: /* initial partition to be computed by sorting */ - fprintf( stderr, + fprintf( out_stderr, "Computing initial partition (sort variable %d) ...\n", NemParaP->SortedVar + 1 ) ; @@ -1113,7 +1112,7 @@ static int ClassifyByNemOneBeta /*V1.04-a*/ case INIT_LABEL: - fprintf( stderr, + fprintf( out_stderr, "Initializing centers from partially labeled sample\n"); if ( flog != NULL ) { @@ -1150,7 +1149,7 @@ static int ClassifyByNemOneBeta /*V1.04-a*/ case INIT_PARAM_FILE: - fprintf( stderr, + fprintf( out_stderr, "Initializing parameters from given value\n"); if ( flog != NULL ) { @@ -1342,7 +1341,7 @@ static int MakeParaFromLabeled if ( sts != STS_OK ) { if ( sts == STS_W_EMPTYCLASS ) - fprintf( stderr, "Class %d has no labeled observation\n", emptyk ) ; + fprintf( out_stderr, "Class %d has no labeled observation\n", emptyk ) ; return sts ; } @@ -1353,7 +1352,7 @@ static int MakeParaFromLabeled /* If there is no observation, draw mean randomly in min-max range */ if ( ParaP->NbObs_KD[ k * nd + d ] < EPSILON ) { - fprintf( stderr , + fprintf( out_stderr , "Warning: no data in class k=%d, variable=%d\n" , k + 1 , d + 1 ); *misskP = k ; @@ -1483,7 +1482,7 @@ static void StartLogFile( const char* LogName, int Npt, FILE** FlogP ) if ( ( (*FlogP) = fopen( LogName, "w" ) ) == NULL ) { - fprintf( stderr, "Could not open file '%s' in write mode\n", + fprintf( out_stderr, "Could not open file '%s' in write mode\n", LogName ) ; } else @@ -1627,7 +1626,7 @@ static StatusET RandNemAlgo irandom < NemParaP->NbRandomInits ; irandom ++ ) { - fprintf( stderr, + fprintf( out_stderr, "\nRandom initial partition %d\n", irandom + 1 ) ; if ( Flog != NULL ) @@ -1719,13 +1718,13 @@ static StatusET RandNemAlgo *CriterP = bestCritS ; - fprintf( stderr, + fprintf( out_stderr, "Best start was %d (%s = %g)\n", bestTry+1, CritStrVC[ NemParaP->Crit ] , ChosenCrit( CriterP , NemParaP->Crit ) ) ; if ( CriterP->Errinfo.Kr != 0 ) - fprintf( stderr, "Error of best start = %5.1f\n", + fprintf( out_stderr, "Error of best start = %5.1f\n", 100.0 * CriterP->Errcur.Errorrate ) ; if ( Flog != NULL ) @@ -1782,8 +1781,8 @@ static int NemAlgo oldcrit = -MAXFLOAT ; WriteLogHeader( Flog, NemParaP->NbEIters, DataP->NbVars, SpecP ) ; - fprintf( stderr, " Iterations : " ) ; - fprintf( stderr, "%4d ", 0 ) ; /*V1.05-g*/ + fprintf( out_stderr, " Iterations : " ) ; + fprintf( out_stderr, "%4d ", 0 ) ; /*V1.05-g*/ /* For each iteration of NEM (until : convergence, or iteration count reached, or empty class) */ @@ -1793,8 +1792,8 @@ static int NemAlgo ( err == STS_OK ) ; iter ++ ) { - fprintf( stderr, "\b\b\b\b\b" ) ; /*V1.05-g*/ - fprintf( stderr, "%4d ", iter ) ; /*V1.05-g*/ + fprintf( out_stderr, "\b\b\b\b\b" ) ; /*V1.05-g*/ + fprintf( out_stderr, "%4d ", iter ) ; /*V1.05-g*/ if ( Flog != NULL ) fprintf( Flog, "%4d ", iter ) ; @@ -1831,7 +1830,7 @@ static int NemAlgo } else if ( err == STS_W_EMPTYCLASS ) /* Else -> class emptyk is empty */ { - fprintf( stderr, "Class %d empty at iteration %d\n", + fprintf( out_stderr, "Class %d empty at iteration %d\n", emptyk, iter ) ; if ( Flog != NULL ) fprintf( Flog, " Class %d empty at iteration %d\n", @@ -1853,12 +1852,12 @@ static int NemAlgo ComputeCrit( npt, nk, ParaP->Beta, CM, SpatialP, WorkP, CriterP ) ; CalcError( CM, npt, 1, & CriterP->Errinfo, & CriterP->Errcur ); - fprintf( stderr, "\n" ) ; /* -> to end iterations count line */ - fprintf( stderr, + fprintf( out_stderr, "\n" ) ; /* -> to end iterations count line */ + fprintf( out_stderr, " criterion NEM = %6.3f / Ps-Like = %6.3f / Lmix = %6.3f\n" , CriterP->U , CriterP->M , CriterP->L ) ; /*V1.03-g*/ if ( CriterP->Errinfo.Kr != 0 ) - fprintf( stderr, " error = %5.3f\n", CriterP->Errcur.Errorrate ) ; + fprintf( out_stderr, " error = %5.3f\n", CriterP->Errcur.Errorrate ) ; /* If convergence test was requested and no error occurred */ if ( ( NemParaP->CvTest != CVTEST_NONE ) && ( err == STS_OK ) ) @@ -1866,11 +1865,11 @@ static int NemAlgo /* Display message about convergence */ if ( converged ) { - fprintf( stderr, " NEM converged after %d iterations\n", iter ) ; + fprintf( out_stderr, " NEM converged after %d iterations\n", iter ) ; } else { - fprintf( stderr, " NEM did not converge after %d iterations\n", + fprintf( out_stderr, " NEM did not converge after %d iterations\n", iter ) ; } } @@ -2609,7 +2608,7 @@ static int ComputeLocalProba if ( first ) { first = FALSE ; - fprintf( stderr, "Warning : pt %d density = 0\n", Ipt ) ; + fprintf( out_stderr, "Warning : pt %d density = 0\n", Ipt ) ; } } diff --git a/ppanggolin/NEM/nem_arg.c b/ppanggolin/NEM/nem_arg.c deleted file mode 100755 index 39b2927c..00000000 --- a/ppanggolin/NEM/nem_arg.c +++ /dev/null @@ -1,1315 +0,0 @@ -/*\ - - NEM_ARG.C - - Programme NEM (Neighborhood EM) : Traitement des arguments - - Van Mo DANG Janvier 96 - - Steps to add an option : - 1 - check unused option characters by running 'nem_exe' without args - 2 - add option fetching in NemArgs() - 3 - add field to NemParaT in "nem_typ.h" : OptMeaning - 4 - add eventual enum in "nem_typ.h" : OptET - 5 - add eventual string array : OptStrVC - 6 - add option default value : DEFAULT_OPT - 7 - add comment to this header : 1.06-k blabla - 8 - add short help in PrintUsage() : -o [%s ] blabla {%s|%s} - 9 - add long help/vers in "nem_user.txt" - -Vers-mod Date Who Description - -1.03-a 22-AUG-1997 MD '-l' to output logfile (default now is NO log) -1.04-a 04-OCT-1997 MD '-s f myfile.zz' instead of just '-s f' -1.04-b 05-OCT-1997 MD '-B heu ' implemented -1.04-c 09-OCT-1997 MD if "-o -" log name is input base name -1.04-d 10-OCT-1997 MD '-c cvthres' implemented -1.04-e 10-OCT-1997 MD '-S seed' implemented -1.04-f 10-OCT-1997 MD '-O order' implemented -1.04-g 13-OCT-1997 MD '-D' implemented -1.04-h 13-OCT-1997 MD '-R' implemented (reference class) -1.04-i 13-OCT-1997 MD '-C crit' -1.04-j 04-NOV-1997 MD '-I eiter' -1.04-k 11-JAN-1997 MD now '-h general/filein/fileout/examples/vers' -1.05-a 12-JAN-1998 MD '-M miss' implemented -1.05-b 05-FEB-1998 MD add 'M' in '-C crit' -1.06-a 17-JUN-1998 MD ReadStrFile and alloc parameters <- from nem_exe.c -1.06-b 23-JUN-1998 MD use new StatModel structure (old NoiseModel) -1.06-b 01-AUG-1998 MD model switch now '-m norm/lapl p* s**' -1.06-c 03-AUG-1998 MD add '-s mi' and '-s mf' -1.06-d 10-SEP-1998 MD add '-U para|seq' -1.06-e 10-SEP-1998 MD add '-t random|first' -1.06-f 15-SEP-1998 MD add '-G nbit conv step' -1.06-g 21-SEP-1998 MD change '-c 0.01' to '-c {none|[clas]|crit} 0.01' -1.06-h 05-OCT-1998 MD default nb of random inits = D * 5 -1.06-i 05-OCT-1998 MD default crit = CRIT_M -1.07-a 08-APR-1999 MD Add Bernoulli family -1.08-a 20-JUI-2017 GG Add param input by file rather than by arguments -\*/ - -#include "nem_typ.h" /* DataT, ... */ -#include "nem_ver.h" /* PrintVersions */ -#include "nem_hlp.h" /* PrintHelpGeneral ... */ -#include "lib_io.h" /* ReadOpeningComments */ /*V1.06-a*/ -#include "genmemo.h" /* GenAlloc, ... */ /*V1.06-a*/ -#include /* printf, ... */ -#include /* atof, ... */ -#include /* strncpy, ... */ -#include /* time() */ /*V1.04-e*/ - -#include "nem_arg.h" /* prototypes */ - -#define DEFAULT_ALGO ALGO_NEM -#define DEFAULT_BETA 1.0 -#define DEFAULT_BTAMODE BETA_FIX /*V1.04-b*/ -#define DEFAULT_BTAHEUSTEP 0.1 /*V1.04-b*/ -#define DEFAULT_BTAHEUMAX 2.0 /*V1.04-b*/ -#define DEFAULT_BTAHEUDDROP 0.8 /*V1.04-b*/ -#define DEFAULT_BTAHEUDLOSS 0.5 /*V1.04-b*/ -#define DEFAULT_BTAHEULLOSS 0.02 /*V1.04-b*/ -#define DEFAULT_BTAGRADNIT 1 /*V1.06-f*/ -#define DEFAULT_BTAGRADCVTH 0.001 /*V1.06-f*/ -#define DEFAULT_BTAGRADSTEP 0.0 /*V1.06-f*/ -#define DEFAULT_BTAGRADRAND 0 /*V1.06-f*/ -#define DEFAULT_CRIT CRIT_M /*V1.04-h*/ -#define DEFAULT_CVTHRES 0.01 /*V1.04-d*/ -#define DEFAULT_CVTEST CVTEST_CLAS /*V1.06-g*/ -#define DEFAULT_FAMILY FAMILY_NORMAL /*V1.06-b*/ -#define DEFAULT_DISPER DISPER___ /*V1.06-b*/ -#define DEFAULT_PROPOR PROPOR__ /*V1.06-b*/ -#define DEFAULT_FORMAT FORMAT_HARD -#define DEFAULT_INIT INIT_SORT -#define DEFAULT_MISSING MISSING_REPLACE /*V1.05-a*/ -#define DEFAULT_NO_PARAM_FILE NO_PARAM_FILE /*V1.08-a*/ -#define DEFAULT_SORTEDVAR 0 -#define DEFAULT_NEIGHSPEC NEIGH_FOUR -#define DEFAULT_NBITERS 100 -#define DEFAULT_NBEITERS 1 -#define DEFAULT_NBRANDINITS 5 /*V1.06-h*/ -#define DEFAULT_ORDER ORDER_DIRECT /*V1.04-f*/ -#define DEFAULT_UPDATE UPDATE_SEQ /*V1.06-d*/ -#define DEFAULT_TIE TIE_RANDOM /*V1.06-e*/ - - -typedef enum -{ - HELP_GENERAL, - HELP_OPTIONS, - HELP_EXAMPLES, - HELP_FILEIN, - HELP_FILEOUT, - HELP_VERSIONS, - HELP_NB - -} HelpET ; - - -static const char *TypeStrC[ TYPE_NB ] = { "S", "I", "N" } ; /*V1.06-a*/ - -static const char *AlgoStrVC[ ALGO_NB ] = { "nem" , "ncem" , "gem" } ; -static const char *BtaStrVC[ BETA_NB ] = { "fix" , "psgrad", - "heu_d" , "heu_l" } ; - const char *CritStrVC[ CRIT_NB ] = { "U" , "M", "D" , "L" } ; -static const char *CvTestStrVC[ CVTEST_NB ] = { "none", "clas" , "crit" } ; -static const char *FormatStrVC[ FORMAT_NB ] = { "hard", "fuzzy" } ; -static const char *HelpStrVC[ HELP_NB ] = { - "general", - "options", - "examples", - "filein", - "fileout", - "versions" -} ; /* V1.04-k*/ - -static const char *InitStrVC[ INIT_NB ] = { "s", "r", "m", "f", "l" } ; -/*V1.05-a*/ -static const char *MissStrVC[ MISSING_NB ] = { "replace" , "ignore" } ; -/*V1.06-b*/ -static const char *FamilyStrVC[ FAMILY_NB ] = { "norm", "lapl", "bern" } ; -static const char *DisperStrVC[ DISPER_NB ] = { "s__", "sk_", "s_d", "skd" } ; -static const char *ProporStrVC[ PROPOR_NB ] = { "p_", "pk" } ; -static const char *NeighStrVC[ NEIGH_NB ] = { "4", "f" } ; -static const char *OrderStrVC[ ORDER_NB ] = { "direct", "random" } ;/*V1.04-f*/ -static const char *UpdateStrVC[ UPDATE_NB ] = { "seq", "para" } ;/*V1.06-d*/ -static const char *TieStrVC[ TIE_NB ] = { "random", "first" } ;/*V1.06-e*/ - - - -/* ==================== LOCAL FUNCTION PROTOTYPING =================== */ - - -/* ==================== GLOBAL FUNCTION DEFINITION =================== */ - - -/* ------------------------------------------------------------------- */ -int NemArgs - ( - int Argc, - const char *Argv[], - char *Fname, /* O */ - StatModelT *StatModelP, /* O */ - NemParaT *NemParaP, /* O */ - char* DatadescS, /* O */ - DataT* DataP, /* O */ - ImageNeighT* ImageP, /* O */ - TypeET* SpatialTypeP /* O */ - ) -/* ------------------------------------------------------------------- */ -{ - StatusET err = STS_OK ; - const char* func = "NemArgs" ; - int nk ; - int nbopt ; - int iopt ; - const char** opts; - - int ReadStrFile /*V1.06-a*/ - ( - const char* BaseName, /* I */ - char* Comment, /* O */ - DataT* DataP, /* O */ - ImageNeighT* ImageP, /* O */ - TypeET* TypeP /* O */ - ); - - char GetOptionSwitch( const char *Arg ) ; - int GetEnum( const char* S, const char* SV[], int SizeV );/*V1.04-b*/ - StatusET PrintHelp( const char* HelpType ) ; - - - switch ( Argc ) /*V1.04-k*/ - { - case 1: /* No args : print usage */ - PrintUsage( Argv[ 0 ] ) ; - return STS_I_DONE ; - - case 2: /* 1 arg : only possibility is -v to ask version information */ - if ( GetOptionSwitch( Argv[ 1 ] ) == 'v' ) - { - PrintVersions( stdout ) ; - return STS_I_DONE ; - } - else - return STS_E_ARG ; - - case 3: /* 2 args : -h help or file nk */ - switch( GetOptionSwitch( Argv[ 1 ] ) ) - { - case '?': - case 'h': - return PrintHelp( Argv[2] ) ; - - default: /* continue processing args */ - break; - } - - default: /* 3 or more args : continue processing args */ - break ; - } - - strncpy( Fname, Argv[1], LEN_FILENAME ) ; - sscanf( Argv[2], "%d", &nk ) ; - StatModelP->Spec.K = nk ; - if ( nk <= 0 ) - { - fprintf( stderr, "Nb of classes must be > 0 (here %s)\n", - Argv[2] ) ; - return STS_E_ARG ; - } - - - /* !!! Read structure file */ /*V1.06-a*/ - if ( ( err = ReadStrFile( Fname, - DatadescS, - DataP, - ImageP, - SpatialTypeP ) ) != STS_OK ) - return err ; - - /* !!! Allocate model parameters */ /*V1.06-a*/ - StatModelP->Para.Prop_K = GenAlloc( nk, sizeof(float), - 1, func, "Prop_K" ) ; - StatModelP->Para.Disp_KD = GenAlloc( nk * DataP->NbVars, sizeof(float), - 1, func, "Disp_KD" ) ; - StatModelP->Para.Center_KD = GenAlloc( nk * DataP->NbVars, sizeof(float), - 1, func, "Center_KD" ) ; - - StatModelP->Para.NbObs_K = GenAlloc( nk, sizeof(float), - 1, func, "NbObs_K" ) ; - StatModelP->Para.NbObs_KD = GenAlloc( nk * DataP->NbVars, sizeof(float), - 1, func, "NbObs_KD" ) ; - StatModelP->Para.Iner_KD = GenAlloc( nk * DataP->NbVars, sizeof(float), - 1, func, "NbObs_KD" ) ; - - StatModelP->Desc.DispSam_D = GenAlloc( DataP->NbVars, sizeof(float), - 1, func, "DispSam_D" ); - StatModelP->Desc.MiniSam_D = GenAlloc( DataP->NbVars, sizeof(float), - 1, func, "MiniSam_D" ); - StatModelP->Desc.MaxiSam_D = GenAlloc( DataP->NbVars, sizeof(float), - 1, func, "MaxiSam_D" ); - - /* Set default value of optional parameters */ - StatModelP->Spec.ClassFamily = DEFAULT_FAMILY ; - StatModelP->Spec.ClassDisper = DEFAULT_DISPER ; - StatModelP->Spec.ClassPropor = DEFAULT_PROPOR ; - - - NemParaP->Algo = DEFAULT_ALGO ; - StatModelP->Para.Beta = DEFAULT_BETA ; /*V1.06-b*/ - StatModelP->Spec.BetaModel = DEFAULT_BTAMODE ; /*V1.04-b*/ - NemParaP->BtaHeuStep = DEFAULT_BTAHEUSTEP ; /*V1.04-b*/ - NemParaP->BtaHeuMax = DEFAULT_BTAHEUMAX ; - NemParaP->BtaHeuDDrop = DEFAULT_BTAHEUDDROP ; - NemParaP->BtaHeuDLoss = DEFAULT_BTAHEUDLOSS ; - NemParaP->BtaHeuLLoss = DEFAULT_BTAHEULLOSS ; - NemParaP->BtaPsGrad.NbIter = DEFAULT_BTAGRADNIT ;/*V1.06-g*/ - NemParaP->BtaPsGrad.ConvThres = DEFAULT_BTAGRADCVTH ; - NemParaP->BtaPsGrad.Step = DEFAULT_BTAGRADSTEP ; - NemParaP->BtaPsGrad.RandInit = DEFAULT_BTAGRADRAND ; - NemParaP->Crit = DEFAULT_CRIT ; /*V1.04-h*/ - NemParaP->CvThres = DEFAULT_CVTHRES ; /*V1.04-d*/ - NemParaP->CvTest = CVTEST_CLAS ; /*V1.06-g*/ - NemParaP->DoLog = FALSE ; /*V1.03-a previously TRUE*/ - NemParaP->NbIters = DEFAULT_NBITERS ; - NemParaP->NbEIters = DEFAULT_NBEITERS ; - NemParaP->NbRandomInits = DEFAULT_NBRANDINITS*DataP->NbVars ; /*V1.06-h*/ - NemParaP->Seed = time( NULL ) ; /*V1.04-e*/ - NemParaP->Format = DEFAULT_FORMAT ; - NemParaP->InitMode = DEFAULT_INIT ; - NemParaP->ParamFileMode = DEFAULT_NO_PARAM_FILE ; - NemParaP->SortedVar = DEFAULT_SORTEDVAR ; - NemParaP->NeighSpec = DEFAULT_NEIGHSPEC ; - NemParaP->VisitOrder = DEFAULT_ORDER ; /*V1.04-f*/ - NemParaP->SiteUpdate = DEFAULT_UPDATE ; /*V1.06-d*/ - NemParaP->TieRule = DEFAULT_TIE ; /*V1.06-e*/ - NemParaP->Debug = FALSE ; /*V1.04-g*/ - strncpy( NemParaP->OutBaseName, Fname, LEN_FILENAME ) ; - strncpy( NemParaP->NeighName, Fname, LEN_FILENAME ) ; - strncat( NemParaP->NeighName, ".nei", LEN_FILENAME ) ; - strncpy( NemParaP->RefName, "", LEN_FILENAME ) ; - - /* Treat options */ - nbopt = Argc - 3 ; - opts = & ( Argv[ 3 ] ) ; - - for ( iopt = 0, err = STS_OK ; - ( iopt < nbopt ) && ( err == STS_OK ) ; - iopt ++ ) - { - char copt = GetOptionSwitch( opts[ iopt ] ) ; - - if ( copt != '\0' ) - switch( copt ) - { - case 'a' : /* next arg is type of algorithm */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->Algo = GetEnum( opts[ iopt ], AlgoStrVC, ALGO_NB ) ; - if ( NemParaP->Algo == -1 ) - { - fprintf( stderr, " Unknown type of algorithm %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'b' : /* next arg is beta */ - iopt ++ ; - if ( iopt < nbopt ) - { - StatModelP->Para.Beta = atof( opts[ iopt ] ) ; - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'c' : /* next arg : conv test */ /*V1.04-d*/ /*V1.06-g*/ - iopt ++ ; - if ( iopt < nbopt ) /* conv test given */ { - NemParaP->CvTest=GetEnum( opts[ iopt ], CvTestStrVC, CVTEST_NB ); - if ( NemParaP->CvTest == -1 ) { - fprintf( stderr, " Unknown convergence test %s\n", opts[iopt] ) ; - err = STS_E_ARG ; - } - else if ( NemParaP->CvTest != CVTEST_NONE ) /* get threshold */ { - iopt ++ ; - if ( iopt < nbopt ) /* threshold given */ { - NemParaP->CvThres = atof( opts[ iopt ] ) ; - if ( NemParaP->CvThres <= 0 ) { - fprintf( stderr, " Conv threshold must be > 0 (here %s)\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } /* else threshold > 0 : OK */ - } - else /* threshold not given */ { - fprintf( stderr, " Expected threshold for conv test %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - } /* threshold checked */ - } /* conv test given */ - else { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'f' : /* next arg is partition input/output format */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->Format=GetEnum( opts[ iopt ], FormatStrVC, FORMAT_NB ); - if ( NemParaP->Format == -1 ) - { - fprintf( stderr, " Unknown format %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'i' : /* next arg is number of iterations */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->NbIters = atoi( opts[ iopt ] ) ; - if ( NemParaP->NbIters < 0 ) - { - fprintf( stderr, "Nb iterations must be >= 0 (here %s)\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'l' : /* next arg is 'y' if log requested */ /*V1.03-a*/ - iopt ++ ; - if ( iopt < nbopt ) - { - if ( opts[ iopt ][ 0 ] == 'y' ) - NemParaP->DoLog = TRUE ; - else - NemParaP->DoLog = FALSE ; - } - else - { - fprintf( stderr, " Expected y or n after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'm' : /* next 3 args is stat model */ /*V1.06-b*/ - if ( iopt + 3 < nbopt ) - { - iopt ++ ; - StatModelP->Spec.ClassFamily = - GetEnum( opts[ iopt ], FamilyStrVC, FAMILY_NB ); - if ( StatModelP->Spec.ClassFamily == -1 ) - { - fprintf( stderr, " Unknown family %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - iopt ++ ; - StatModelP->Spec.ClassPropor = - GetEnum( opts[ iopt ], ProporStrVC, PROPOR_NB ); - if ( StatModelP->Spec.ClassPropor == -1 ) - { - fprintf( stderr, " Unknown proportion %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - iopt ++ ; - StatModelP->Spec.ClassDisper = - GetEnum( opts[ iopt ], DisperStrVC, DISPER_NB ); - if ( StatModelP->Spec.ClassDisper == -1 ) - { - fprintf( stderr, " Unknown dispersion %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected 3 values after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'n' : /* next arg is neighborhood specification */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->NeighSpec=GetEnum( opts[ iopt ], NeighStrVC, NEIGH_NB); - if ( NemParaP->NeighSpec == -1 ) - { - fprintf( stderr, " Unknown neighborhood specification %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'o' : /* next arg is output file name */ - iopt ++ ; - if ( iopt < nbopt ) - { - strncpy( NemParaP->OutBaseName, opts[ iopt ], LEN_FILENAME ) ; - } - else - { - fprintf( stderr, " Expected file name after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 's' : /* next arg is initialization mode */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->InitMode = GetEnum( opts[ iopt ], InitStrVC, INIT_NB ); - - switch( NemParaP->InitMode ) { - - case INIT_SORT: /* next arg is sorted var */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->SortedVar = atoi( opts[ iopt ] ) - 1 ; - } - else - { - fprintf( stderr, - " Expected variable index after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - case INIT_RANDOM: /* next arg is number of initializations */ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->NbRandomInits = atoi( opts[ iopt ] ) ; - } - else - { - fprintf( stderr, - " Expected nb of trials after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - case INIT_FILE: /* next arg is name of initial partition */ - iopt ++ ; /*V1.04-a*/ - if ( iopt < nbopt ) - { - strncpy( NemParaP->StartName, opts[ iopt ], - LEN_FILENAME ) ; - } - else - { - fprintf( stderr, - " Expected file name after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - case INIT_LABEL:/* next arg is name of partial labels */ - iopt ++ ; - if ( iopt < nbopt ) - { - strncpy( NemParaP->LabelName, opts[ iopt ], - LEN_FILENAME ) ; - } - else - { - fprintf( stderr, - " Expected file name after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - case INIT_PARAM_FILE: /* next args are parameter values */ - - iopt ++ ; /*V1.08-a*/ - if ( iopt < nbopt ) - { - strncpy( NemParaP->ParamName, opts[ iopt ], - LEN_FILENAME ) ; - } - else - { - fprintf( stderr, - " Expected file name after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - break ; - - default: - fprintf( stderr, " Unknown init mode %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected init mode after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 't' : /* next arg is MAP tie rule */ /*V1.06-e*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->TieRule=GetEnum(opts[ iopt ],TieStrVC,TIE_NB); - if ( NemParaP->TieRule == -1 ) - { - fprintf( stderr, " Unknown tie rule %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - case 'B' : /* next arg is beta estimation method */ /*V1.04-b*/ - iopt ++ ; - if ( iopt < nbopt ) - { - StatModelP->Spec.BetaModel = - GetEnum( opts[ iopt ], BtaStrVC, BETA_NB ); - if ( StatModelP->Spec.BetaModel == -1 ) - { - fprintf( stderr, " Unknown type of beta estimation %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - else { - if ( ( StatModelP->Spec.BetaModel == BETA_HEUL ) | - ( StatModelP->Spec.BetaModel == BETA_HEUD ) ) - NemParaP->Crit = CRIT_U ; /* force to choose U criterion */ - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - case 'C' : /* next arg is crit to choose local max */ /*V1.04-i*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->Crit = GetEnum( opts[ iopt ], CritStrVC, CRIT_NB ); - if ( NemParaP->Crit == -1 ) - { - fprintf( stderr, " Unknown criterion name %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - case 'G' : /* next 4 args are parameters of beta gradient */ - if ( iopt + 4 < nbopt ) - { - NemParaP->BtaPsGrad.NbIter = atof( opts[ iopt + 1 ] ) ; - NemParaP->BtaPsGrad.ConvThres = atof( opts[ iopt + 2 ] ) ; - NemParaP->BtaPsGrad.Step = atof( opts[ iopt + 3 ] ) ; - NemParaP->BtaPsGrad.RandInit = atoi( opts[ iopt + 4 ] ) ; - iopt += 4 ; - } - else - { - fprintf( stderr, " Expected 4 values after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - - case 'H' : /* next 5 args are parameters of beta heuristic */ - if ( iopt + 5 < nbopt ) - { - NemParaP->BtaHeuStep = atof( opts[ iopt + 1 ] ) ; - NemParaP->BtaHeuMax = atof( opts[ iopt + 2 ] ) ; - NemParaP->BtaHeuDDrop = atof( opts[ iopt + 3 ] ) ; - NemParaP->BtaHeuDLoss = atof( opts[ iopt + 4 ] ) ; - NemParaP->BtaHeuLLoss = atof( opts[ iopt + 5 ] ) ; - iopt += 5 ; - } - else - { - fprintf( stderr, " Expected 4 values after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'I' : /* next arg is number of E-step iterations */ /*V1.04-j*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->NbEIters = atoi( opts[ iopt ] ) ; - if ( NemParaP->NbEIters < 0 ) - { - fprintf( stderr, "Nb iterations must be >= 0 (here %s)\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'M' : /* next arg is missing data mode */ /*V1.05-a*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->MissMode=GetEnum(opts[ iopt ], MissStrVC, MISSING_NB); - if ( NemParaP->MissMode == -1 ) - { - fprintf( stderr, " Unknown missing mode %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - case 'O' : /* next arg is visit order type */ /*V1.04-f*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->VisitOrder=GetEnum(opts[ iopt ], OrderStrVC, ORDER_NB); - if ( NemParaP->VisitOrder == -1 ) - { - fprintf( stderr, " Unknown visit order type %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - case 'R' : /* next arg is reference class file */ /*V1.04-h*/ - iopt ++ ; - if ( iopt < nbopt ) - { - strncpy( NemParaP->RefName, opts[ iopt ], LEN_FILENAME ) ; - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - - case 'S' : /* next arg is random generator seed */ /*V1.04-e*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->Seed = atol( opts[ iopt ] ) ; - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'T' : /* set debug mode to be true */ /*V1.04-g*/ - NemParaP->Debug = TRUE ; - break ; - - - case 'U' : /* next arg is site update mode */ /*V1.06-d*/ - iopt ++ ; - if ( iopt < nbopt ) - { - NemParaP->SiteUpdate=GetEnum(opts[ iopt ],UpdateStrVC,UPDATE_NB); - if ( NemParaP->SiteUpdate == -1 ) - { - fprintf( stderr, " Unknown site update mode %s\n", - opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - - case 'v' : /* print out version information */ - PrintVersions( stdout ) ; - err = STS_I_DONE ; - break ; - - - case '?' : /* long help requested */ - case 'h' : /*V1.04-k*/ - iopt ++ ; - if ( iopt < nbopt ) - { - err = PrintHelp( opts[ iopt ] ) ; - } - else - { - fprintf( stderr, " Expected value after switch %s\n", - opts[ iopt - 1 ] ) ; - err = STS_E_ARG ; - } - break ; - - default : - fprintf( stderr, "Unknown option switch '%s'\n", opts[ iopt ] ) ; - err = STS_E_ARG ; - } /* end if ( copt != '\0' ) switch ( copt ) */ - else - { - fprintf( stderr, " Expected an option switch at arg %d (%s)\n", - iopt + 3 , opts[ iopt ] ) ; - err = STS_E_ARG ; - } - } /* end for ( iopt ... ) */ - - strncpy( NemParaP->OutName, NemParaP->OutBaseName, LEN_FILENAME ) ; - strncat( NemParaP->OutName, - NemParaP->Format == FORMAT_HARD ? EXT_OUTNAMEHARD : EXT_OUTNAMEFUZZY, - LEN_FILENAME ) ; - - if ( NemParaP->DoLog ) - { - if ( strcmp( NemParaP->OutBaseName , "-" ) != 0 ) /*V1.04-c*/ - { - strncpy( NemParaP->LogName, NemParaP->OutBaseName, LEN_FILENAME ) ; - strncat( NemParaP->LogName, EXT_LOGNAME, LEN_FILENAME ) ; - } - else - { - strncpy( NemParaP->LogName, Fname , LEN_FILENAME ) ; - strncat( NemParaP->LogName, EXT_LOGNAME, LEN_FILENAME ) ; - } - } - else - { - strcpy( NemParaP->LogName, "" ) ; - } - - return err ; - -} /* end of NemArgs() */ - - - -/* ==================== LOCAL FUNCTION DEFINITION =================== */ - - - -/* ------------------------------------------------------------------- */ -int ReadStrFile - ( - const char* BaseName, /* I */ - char* CommentS, /* O */ - DataT* DataP, /* O */ - ImageNeighT* ImageP, /* O */ - TypeET* TypeP /* O */ - ) -/*\ - Read structure file - expected format : - type size nbvars - type : N | I | S - size : (if type == I) lx ly (if type == N or S) nbpts - nbvars : integer -\*/ -/* ------------------------------------------------------------------- */ -{ - char infname[ LEN_FILENAME + 1 ] ; - FILE *fstr ; - int nbelts ; - char type[100] ; /* N | I | S */ - int n1, n2, n3 ; - - void my_strupr( char *s ) ; - - strncpy( infname, BaseName, LEN_FILENAME ) ; - strncat( infname, ".str" , LEN_FILENAME ) ; - - if ( ReadOpeningComments( infname , "#" , LEN_LINE , - & fstr , CommentS ) == -1 ) - { - fprintf( stderr, "File %s does not exist\n", infname ) ; - return STS_E_FILEIN ; - } - - - /* Now we expect a line having structure : "I nl nc d" or "S n d" or - "N n d" - */ - nbelts = fscanf( fstr, "%s %d %d %d", type, &n1, &n2, &n3 ) ; - fclose( fstr ) ; /*V1.05-h*/ - - if ( nbelts < 3 ) - { - fprintf( stderr, "Structure file (%s) not enough fields\n", - infname ) ; - return STS_E_FILE ; - } - - my_strupr( type ) ; - - if ( ! strcmp( type, TypeStrC[ TYPE_NONSPATIAL ] ) ) - { - /* No spatial information */ - DataP->NbPts = n1 ; - DataP->NbVars = n2 ; - *TypeP = TYPE_NONSPATIAL ; - } - else if ( ! strcmp( type, TypeStrC[ TYPE_SPATIAL ] ) ) - { - /* Spatial irregular */ - DataP->NbPts = n1 ; - DataP->NbVars = n2 ; - *TypeP = TYPE_SPATIAL ; - } - else if ( ! strcmp( type, TypeStrC[ TYPE_IMAGE ] ) ) - { - /* Image */ - if ( nbelts < 4 ) - { - fprintf( stderr, "Structure file (%s) not enough fields\n", - infname ) ; - return STS_E_FILE ; - } - ImageP->Nl = n1 ; - ImageP->Nc = n2 ; - DataP->NbPts = ImageP->Nl * ImageP->Nc ; - DataP->NbVars = n3 ; - *TypeP = TYPE_IMAGE ; - } - else - { - /* default : Error in structure file */ - fprintf( stderr, "Data type %s unknown in file %s\n", - type, infname ) ; - return STS_E_FILE ; - } - - return STS_OK ; - -} /* end of ReadStrFile() */ - - - - -/* ------------------------------------------------------------------- */ -char GetOptionSwitch( const char *Arg ) -/* ------------------------------------------------------------------- */ -{ - if ( ( Arg[ 0 ] == '-' ) || ( Arg[ 0 ] == '/' ) ) - { - return Arg[ 1 ] ; - } - else - { - return '\0' ; - } -} /* end of GetOptionSwitch() */ - - -/* ------------------------------------------------------------------- */ -int GetEnum( const char* S, const char* SV[], int SizeV ) /*V1.04-b*/ -/*\ - - Returns the position of string S in the array SV consisting of - SizeV strings (indiced from 0 to SizeV - 1). Returns -1 if S is - not found in SV. - -\*/ -/* ------------------------------------------------------------------- */ -{ - int pos ; - int found ; - - for ( pos = 0 , found = FALSE ; - ( pos < SizeV ) && ( ! found ) ; - pos ++ ) - { - if ( ! strcmp( S , SV[ pos ] ) ) - found = TRUE ; - } - - if ( found ) - return ( pos - 1 ) ; /* '- 1' because for() adds 1 after finding */ - else - return -1 ; -} - -/* ------------------------------------------------------------------- */ -void PrintUsage( const char* CmdName ) -/* ------------------------------------------------------------------- */ -{ - fprintf( stderr, "Usage : " ) ; - fprintf( stderr, " %s file nk [ option1 option2 ... ]\n\n", - CmdName ) ; - fprintf( stderr, " file base name of input and output files\n" ) ; - fprintf( stderr, " nk number of classes\n\n" ) ; - - fprintf( stderr, "Options : [ default ]\n\n" ) ; - - fprintf( stderr, " -a algo [ %-8s ] type of algorithm { ", - AlgoStrVC[ DEFAULT_ALGO ] ) ; - { - AlgoET ialgo ; - - for ( ialgo = 0 ; ialgo < ALGO_NB ; ialgo ++ ) - fprintf( stderr, "%s ", AlgoStrVC[ ialgo ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -b beta [ %-8g ] spatial coefficient, >= 0.0\n", - DEFAULT_BETA ) ; - - fprintf( stderr, " -c wh thr [%4s %5.3g] convergence test { ", - CvTestStrVC[ DEFAULT_CVTEST ], DEFAULT_CVTHRES ) ; - { - CvemET icvtest ; - - for ( icvtest = 0 ; icvtest < CVTEST_NB ; icvtest ++ ) - fprintf( stderr, "%s ", CvTestStrVC[ icvtest ] ) ; - } - fprintf( stderr, "} + threshold (>0)\n" ) ; /*V1.04-d*//*V1.06-g*/ - - fprintf( stderr, " -f format [ %-8s ] partition format, { ", - FormatStrVC[ DEFAULT_FORMAT ] ) ; - { - FormET ipart ; - - for ( ipart = 0 ; ipart < FORMAT_NB ; ipart ++ ) - fprintf( stderr, "%s ", FormatStrVC[ ipart ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -i itmax [ %-8d ] number of NEM iterations (>= 0)\n", - DEFAULT_NBITERS ) ; - - fprintf( stderr, " -l dolog [ n ] log file or not { y n }\n" ) ; /*V1.03-a*/ - - fprintf( stderr, " -m f p d [%-4s %-2s %-3s] model {", - FamilyStrVC[ DEFAULT_FAMILY ], - ProporStrVC[ DEFAULT_PROPOR ], - DisperStrVC[ DEFAULT_DISPER ] ) ; - { - int imodel ; - - for ( imodel = 0 ; imodel < FAMILY_NB - 1 ; imodel ++ ) - fprintf( stderr, "%s ", FamilyStrVC[ imodel ] ) ; - fprintf( stderr, "%s", FamilyStrVC[ FAMILY_NB - 1 ] ) ; - fprintf( stderr, "} {" ) ; - for ( imodel = 0 ; imodel < PROPOR_NB - 1 ; imodel ++ ) - fprintf( stderr, "%s ", ProporStrVC[ imodel ] ) ; - fprintf( stderr, "%s", ProporStrVC[ PROPOR_NB - 1 ] ) ; - fprintf( stderr, "} {" ) ; - for ( imodel = 0 ; imodel < DISPER_NB - 1 ; imodel ++ ) - fprintf( stderr, "%s ", DisperStrVC[ imodel ] ) ; - fprintf( stderr, "%s", DisperStrVC[ DISPER_NB - 1 ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -n neigh [ %-8s ] neighbour specification (image), { ", - NeighStrVC[ DEFAULT_NEIGHSPEC ] ) ; - { - NeighET inei ; - - for ( inei = 0 ; inei < NEIGH_NB ; inei ++ ) - fprintf( stderr, "%s ", NeighStrVC[ inei ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -o fout [ file ] output files basename\n" ) ; - - fprintf( stderr, " -s init [ s 1 ] init : " ) ; - fprintf( stderr, "s = sort var \n" ) ; - fprintf( stderr, "%33s f = from \n", " " ) ; /*V1.04-a*/ - fprintf( stderr, "%33s r = random inits\n", " " ) ; - fprintf( stderr, "%33s l = use known labels from \n", " " ) ; - fprintf( stderr, "%33s m = initial/fixed parameters\n", " " ) ; /*V1.08-a*/ - - fprintf( stderr, "--- Press return for more options ---" ) ; - getchar( ) ; - - fprintf( stderr, " -t tie [ %-8s ] MAP tie rule { ", - TieStrVC[ DEFAULT_TIE ] ) ; - { - TieET itie ; - - for ( itie = 0 ; itie < TIE_NB ; itie ++ ) - fprintf( stderr, "%s ", TieStrVC[ itie ] ) ; - } - fprintf( stderr, "}\n" ) ; - - - fprintf( stderr, " -B bmod [ %-8s ] b estimation mode { ", - BtaStrVC[ DEFAULT_BTAMODE ] ) ; - { - BetaET bmod ; - for (bmod = 0; bmod < BETA_NB; bmod ++) - fprintf( stderr, "%s ", BtaStrVC[ bmod ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -C crit [ %-8s ] local maximum criterion { ", - CritStrVC[ DEFAULT_CRIT ] ) ; - { - CritET crit ; - for (crit = 0; crit < CRIT_NB; crit ++) - fprintf( stderr, "%s ", CritStrVC[ crit ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -G nit conv step rand [ %2d %5.3f %3.1f %1d ] %s\n", - DEFAULT_BTAGRADNIT, DEFAULT_BTAGRADCVTH, DEFAULT_BTAGRADSTEP, - DEFAULT_BTAGRADRAND, - "parameters of beta gradient estimation") ; - - fprintf( stderr, " -H bstep bmax ddrop dloss lloss [ %3.2f %3.1f %3.1f %3.1f %3.2f ]\n %33s %s\n", - DEFAULT_BTAHEUSTEP, DEFAULT_BTAHEUMAX, DEFAULT_BTAHEUDDROP, - DEFAULT_BTAHEUDLOSS, DEFAULT_BTAHEULLOSS, " ", - "parameters of beta heuristic") ; - - fprintf( stderr, " -I eiter [ %-8d ] number of E-step iterations (>= 1)\n", - DEFAULT_NBEITERS ) ;/*V1.04-j*/ - - - fprintf( stderr, " -M miss [ %-8s ] missing data processing { ", - MissStrVC[ DEFAULT_MISSING ] ) ; - { - MissET imissing ; - - for ( imissing = 0 ; imissing < MISSING_NB ; imissing ++ ) - fprintf( stderr, "%s ", MissStrVC[ imissing ] ) ; - } - fprintf( stderr, "}\n" ) ; - - - fprintf( stderr, " -O order [ %-8s ] order of site visit { ", - OrderStrVC[ DEFAULT_ORDER ] ) ; - { - OrderET iorder ; - - for ( iorder = 0 ; iorder < ORDER_NB ; iorder ++ ) - fprintf( stderr, "%s ", OrderStrVC[ iorder ] ) ; - } - fprintf( stderr, "}\n" ) ; - - fprintf( stderr, " -S seed [