

def main(**kwargs):
    if (len(kwargs) == 0):
        opts = parser.parse_args(sys.argv[1:])
    else:
        opts = parser.parse_args(kwargs)
    if (opts.mappings_id == None):
        parser.print_help()
        sys.exit(1)
    mappingsTable = dxpy.DXGTable(opts.mappings_id)
    if (opts.file_name != None):
        fh = open(opts.file_name, 'w')
    else:
        fh = sys.stdout
    if ('quality' in mappingsTable.get_col_names()):
        outputFastq = True
    else:
        outputFastq = False
    for row in mappingsTable.iterate_rows(want_dict=True):
        if outputFastq:
            writeFastq(row, fh)
        else:
            writeFasta(row, fh)

dataset/ETHPy150Open dnanexus/dx-toolkit/src/python/dxpy/scripts/dx_mappings_to_fastq.py main/original