export_features_sign0.py 1.72 KB
Newer Older
nsoler's avatar
nsoler committed
1
2
3
4
5
## NS (08 Feb 2021), export the features from sign0
## So as 'sanitize' (i.e remove columns) identically as in the cc-rep when a custom dataset is made
## in A spaces

from chemicalchecker.core.chemcheck import ChemicalChecker
nsoler's avatar
nsoler committed
6
7
from get_repo_version import cc_repo_version
#VERSION= "2020_02"
nsoler's avatar
nsoler committed
8

nsoler's avatar
nsoler committed
9
def export_features_sign0(destination="/aloy/scratch/nsoler/CC_related/EXPORT_SIGN/sign0_features", spaces="ABCDE", cc_repo=None):
nsoler's avatar
nsoler committed
10

nsoler's avatar
nsoler committed
11
    if cc_repo is None:
nsoler's avatar
nsoler committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
        cc_repo = cc_repo_version()

        if cc_repo is None:
            print("ERROR, cannot guess the latest cc repository path")
            print("Please provide it as an argument")
            print("ex: cc_repo='/aloy/web_checker/package_cc/2020_02'")
            return
        else:
            print("Working with cc_repo:",cc_repo)

    if not os.path.exists(destination):
        try:
            os.makedirs(destination)
        except Exception as e:
            print("ERROR while attempting to create destination folder", destination)
            print(e)
        else:
            print("Created directory", destination)

    cc = ChemicalChecker(cc_repo)

nsoler's avatar
nsoler committed
33
    for space in spaces:
nsoler's avatar
nsoler committed
34
35
        for num in (1, 2, 3, 4, 5):
            ds= space+str(num)+'.001'
nsoler's avatar
nsoler committed
36
37
38
39
40
41
42
43
44
45
            tmpdir=os.path.join(destination, ds)

            if not os.path.exists(tmpdir):
                try:
                    os.makedirs(tmpdir)

                except Exception as e:
                    print("WARNING", e)
                    continue

nsoler's avatar
nsoler committed
46
47
            sign0tmp = cc.get_signature('sign0', 'full', ds)
            sign0tmp.export_features(destination)
nsoler's avatar
nsoler committed
48
49

if __name__== '__main__':
nsoler's avatar
nsoler committed
50
    destination="/aloy/scratch/nsoler/CC_related/EXPORT_SIGN/sign0_features"
nsoler's avatar
nsoler committed
51
    export_features_sign0(destination=destination, spaces="A")