<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def psiblast_n_neighbors(seqs, n=100, blast_db=None, core_threshold=1e-50, extra_threshold=1e-10, lower_threshold=1e-6, step=100, method="two-step", blast_mat_root=None, params={}, add_seq_names=False, WorkingDir=None, SuppressStderr=None, SuppressStdout=None, input_handler=None, scorer=3, #shotgun with 3 hits needed to keep second_db=None ):
 """PsiBlasts sequences, stopping when n neighbors are reached. core_threshold: threshold for the core profile (default: 1e-50) extra_threshold: threshold for pulling in additional seqs (default:1e-10) lower_threshold: threshold for seqs in final round (default:1e-6) seqs: either file name or list of sequence objects or list of strings or single multiline string containing sequences. If you want to skip the detection and force a specific type of input handler, use input_handler='your_favorite_handler'. add_seq_names: boolean. if True, sequence names are inserted in the list of sequences. if False, it assumes seqs is a list of lines of some proper format that the program can handle """

    if blast_db:
        params["-d"] = blast_db

    ih = input_handler or guess_input_handler(seqs, add_seq_names)
    recs = seqs_to_stream(seqs, ih) #checkpointing can only handle one seq...

    #set up the parameters for the core and additional runs
    max_iterations = params['-j']
    params['-j'] = 2    #won't checkpoint with single iteration

    app = PsiBlast(params=params,
                   blast_mat_root=blast_mat_root,
                   InputHandler='_input_as_lines',
                   WorkingDir=WorkingDir,
                   SuppressStderr=SuppressStderr,
                   SuppressStdout=SuppressStdout,
                   )
    result = {}
    for seq in recs:
        query_id = seq[0][1:].split(None,1)[0]
        if method == "two-step":
            result[query_id] = ids_from_seq_two_step(seq, n, max_iterations, \
                app, core_threshold, extra_threshold, lower_threshold, second_db)
        elif method == "lower_threshold":
            result[query_id] = ids_from_seq_lower_threshold(seq, n, \
                max_iterations, app, core_threshold, lower_threshold, step)
        elif method == "iterative":
            result[query_id] = ids_from_seqs_iterative(seq, app, \
               QMEPsiBlast9, scorer, params['-j'], n)
        else:
            raise TypeError, "Got unknown method %s" % method

    params['-j'] = max_iterations
    return result