~ubuntu-branches/ubuntu/trusty/clustalx/trusty

« back to all changes in this revision

Viewing changes to clustalW/general/OutputFile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy, Steffen Moeller, Charles Plessy
  • Date: 2009-10-21 13:25:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091021132544-r4hbcnjxp354wxh0
Tags: 2.0.12-1
* New upstream release (LP: #423648, #393769):
  - Uses Qt instead of lesstif.
  - Includes new code for UPGMA guide trees.
  - Includes iterative alignment facility.

[ Steffen Moeller ]
* New upstream release.
* Updated watch file (Closes: #550893).
* Removed LICENSE from debian/clustalx.docs
* rename to clustalx seems no longer required in debian/rules
* moved clustalx.1 into debian folder (eases working with svn-buildpackage)
* added German translation to desktop file

[ Charles Plessy ]
* Updated my email address.
* debian/copyright made machine-readable.
* Added various informations in debian/upstream-metadata.yaml.
* Switched to Debhelper 7.
  (debian/rules, debian/control, debian/patches, debian/compat)
* Removed useless Debhelper file debian/clustalx.dirs.
* Updated package description.
* Hardcoded the localisation of accessory files in /usr/share/clustalx.
  (debian/patches/hardcode-accessory-file-locations.patch)
* Documented in debian/README.source that the documentation for quilt
  is in /usr/share/doc/quilt.
* Added upstream changelog downloaded from upstream website
  (debian/rules, debian/CHANGELOG.upstream).
* Incremented Standards-Version to reflect conformance with Policy 3.8.3
  (debian/control, no other changes needed).
* Updated homepage in debian/clustalw.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Author: Mark Larkin
 
3
 * 
 
4
 * Copyright (c) 2007 Des Higgins, Julie Thompson and Toby Gibson.  
 
5
 */
 
6
#ifdef HAVE_CONFIG_H
 
7
    #include "config.h"
 
8
#endif
 
9
#include "OutputFile.h"
 
10
#include "utils.h"
 
11
#include "userparams.h"
 
12
 
 
13
namespace clustalw
 
14
{
 
15
 
 
16
OutputFile::OutputFile()
 
17
{
 
18
 
 
19
}
 
20
 
 
21
OutputFile::~OutputFile()
 
22
{
 
23
    // If it is open, close it and say that a file has been created!!!!!
 
24
    if(file.get())
 
25
    {
 
26
        file->close();
 
27
        utilityObject->info("%s file created:   [%s]\n", typeOfFileMsg.c_str(),
 
28
                                name.c_str());                         
 
29
    }
 
30
}
 
31
 
 
32
bool OutputFile::openFile(std::string* fileName, const std::string msg, const std::string* path, 
 
33
                      const std::string ext, const std::string fileType)
 
34
{
 
35
    if (fileName->empty())
 
36
    {
 
37
        *fileName = getOutputFileName(msg, *path, ext);
 
38
            
 
39
        if(fileName->empty())
 
40
        {
 
41
            return false;
 
42
        }
 
43
    }
 
44
 
 
45
    file.reset(new std::ofstream(fileName->c_str(), std::ofstream::trunc));
 
46
                
 
47
    if(!file->is_open()) 
 
48
    {
 
49
        utilityObject->error("Cannot open output file [%s]\n", fileName->c_str()); 
 
50
        return false;
 
51
    }
 
52
    name = *fileName; 
 
53
    typeOfFileMsg = fileType;
 
54
    
 
55
    return true;
 
56
}
 
57
 
 
58
bool OutputFile::isOpen()
 
59
{
 
60
    return file->is_open();
 
61
}
 
62
 
 
63
std::ofstream* OutputFile::getPtrToFile()
 
64
{
 
65
    return file.get();
 
66
}
 
67
                      
 
68
std::string OutputFile::getOutputFileName(const std::string prompt, std::string path, 
 
69
                                          const std::string fileExtension)
 
70
{
 
71
    std::string temp;
 
72
    std::string _fileName; // Will return this name.
 
73
    std::string message;
 
74
    _fileName = path + fileExtension;
 
75
 
 
76
    if(_fileName.compare(userParameters->getSeqName()) == 0) 
 
77
    {
 
78
        cerr << "WARNING: Output file name is the same as input file.\n";
 
79
        if (userParameters->getMenuFlag()) 
 
80
        {
 
81
            message = "\n\nEnter new name to avoid overwriting  [" + _fileName + "]: ";
 
82
            utilityObject->getStr(message, temp);
 
83
            if(temp != "")
 
84
            {
 
85
                _fileName = temp;
 
86
            }
 
87
        }
 
88
    }
 
89
    else if (userParameters->getMenuFlag()) 
 
90
    {
 
91
 
 
92
        message = prompt + " [" + _fileName + "]";
 
93
        utilityObject->getStr(message, temp);
 
94
        if(temp != "")
 
95
        {
 
96
            _fileName = temp;
 
97
        }
 
98
    }   
 
99
    return _fileName;
 
100
 
 
101
}
 
102
 
 
103
}
 
104
 
 
105