def is_good_mapped_alignment(aln, allow_secondary, min_mapq, allow_qcfail, allow_duplicate):
    """Return True if input alignment aln meets all below criteria:
    * is mapped,
    * its mapping QV is greater than or equal to min_mapq
    * is parimary alignment or secondary alignment is allowed, and
    * has good qc (qc not fail) or allow qcfail
    * is not duplicated or allow duplicated
    """
    return not aln.is_unmapped and \
            (aln.mapping_quality >= min_mapq) and \
            (not aln.is_secondary or allow_secondary) and \
            (not aln.is_qcfail or allow_qcfail) and \
            (not aln.is_duplicate or allow_duplicate)