# acsn2hugo.py -- Convert ACSN entities network to HUGO genes network
#
# jean-daniel.granet@mines-paristech.fr

import sys
import argparse

def main():
    # get arguments : 
    parser = argparse.ArgumentParser(description='Convert ACSN entities network to HUGO genes network')
    parser.add_argument('acsn', help='ACSN entities network to convert, in .sif format')
    parser.add_argument('curated', help='reference file : correspondance between ACSN entities and HUGO genes symbols, in .gmt format')
    parser.add_argument('hugo', help='file to create : genes network using HUGO gene symbols, in sif format')
    args = parser.parse_args()
    
    curated = dict()
    # read the curated file and save into a dictionary :
    # the key is the acsn gene name and the value is the hugo gene name
    # curated [ "acsn entity name" ] = "hugo\tgene\tnames\tin\tthe\tacsn\tentity"
    with open(args.curated, 'r') as fdCurated:
        # File structure : acsn entity name\t description (=na)\tgene\list\in\tHUGO\symbol
        for line in fdCurated:
            line_split = line.split('\tna\t')
            curated[line_split[0].strip()] = line_split[1].strip()
        fdCurated.close()

    # read the acsn network file and write the corresponding hugo network into the output file
    with open(args.acsn, 'r') as fdAcsn:
        # File structure : acsn entity name 1\tName of relationship\t acsn entity name 2
        with open(args.hugo, 'w') as fdHugo:
            #File structure : hugo gene symbol\tName of relationship\thugo gene symbol
            for line in fdAcsn:
                line_split = line.split('\t')
                geneA = curated[line_split[0].strip()].split()
                geneB = curated[line_split[2].strip()].split()
                for elemA in geneA:
                    for elemB in geneB:
                        fdHugo.write("%s\n" % "\n".join(["%s %s %s" % (elemA, line_split[1], elemB)]))
            fdHugo.close()
        fdAcsn.close() 

if __name__ == "__main__":
    main()

# acsn2hugo.py -- Convert ACSN entities network to HUGO genes network
#
# jean-daniel.granet@mines-paristech.fr

import sys
import argparse

def main():
    # get arguments : 
    parser = argparse.ArgumentParser(description='Convert ACSN entities network to HUGO genes network')
    parser.add_argument('acsn_network_fname', help='ACSN entities network to convert, in .sif format')
    parser.add_argument('correspondances_fname', help='reference file : correspondance between ACSN entities and HUGO genes symbols, in .gmt format')
    parser.add_argument('output_fname', help='file to create : genes network using HUGO gene symbols, in sif format')
    args = parser.parse_args()
    
    correspondances = dict()
    # read the correspondances file and save into a dictionary :
    # the key is the acsn gene name and the value is the hugo gene name
    # correspondances [ "acsn entity name" ] = "hugo\tgene\tnames\tin\tthe\tacsn\tentity"
    with open(args.correspondances_fname, 'r') as fdCorrespondances:
        # File structure : acsn entity name\t description (=na)\tgene\list\in\tHUGO\symbol
        for line in fdCorrespondances:
            line_split = line.split('\tna\t')
            ACSN_entity = line_split[0].strip()
            correspondances[ACSN_entity] = line_split[1].strip()
        fdCorrespondances.close()

    # read the acsn network file and write the corresponding hugo network into the output file
    with open(args.acsn_network_fname, 'r') as fdAcsn:
        # File structure : acsn entity name 1\tName of relationship\t acsn entity name 2
        with open(args.output_fname, 'w') as fdOut:
            #File structure : hugo gene symbol\tName of relationship\thugo gene symbol
            for line in fdAcsn: # "acsn entity name 1\tName of relationship\t acsn entity name 2"
                line_split = line.split('\t')# ["acsn entity name 1","Name of relationship","acsn entity name 2"]
                ACSN_entity_A = line_split[0].strip()
                ACSN_entity_B = line_split[2].strip()
                HUGO_genes_symbols_in_ACSN_entity_A = correspondances[ACSN_entity_A].split()
                HUGO_genes_symbols_in_ACSN_entity_B = correspondances[ACSN_entity_B].split()
                for elemA in HUGO_genes_symbols_in_ACSN_entity_A:
                    for elemB in HUGO_genes_symbols_in_ACSN_entity_B:
                        fdOut.write("%s\n" % "\n".join(["%s %s %s" % (elemA, line_split[1], elemB)]))
            fdOut.close()
        fdAcsn.close() 

if __name__ == "__main__":
    main()

Change variable names into mode explicit ones