コード例 #1
0
ファイル: DeepMod.py プロジェクト: lvxuan96/fastDeepMod
def mGetFeatures(margs):
   from scripts import myGetFeatureBasedPos

   # get common options
   moptions, ErrorMessage = mCommonParam(margs)
   # motif-based data: positive or negative control data
   moptions['posneg'] = margs.posneg
   # the number of features: 7-description or 57-description
   moptions['fnum'] = margs.fnum
   ErrorMessage = ErrorMessage + non_negative(moptions['fnum'], 'fnum')
   # size of each bacth to store features
   moptions['size_per_batch'] = margs.size_per_batch
   if moptions['size_per_batch'] < 0.001: moptions['size_per_batch'] = 0.001

   # path to basecall inform in fast5 files
   moptions['basecall_1d'] = margs.basecall_1d
   moptions['basecall_2strand'] = margs.basecall_2strand

   # regions of interest
   moptions['region'] = [None, None, None]
   if not (margs.region==None or margs.region.strip()==''):
      rsp = margs.region.split(':')
      for rv_ind in range(len(rsp)):
         rsp[rv_ind] = rsp[rv_ind].strip();
         if not rsp[rv_ind]=='':
            moptions['region'][rv_ind] = rsp[rv_ind]

   # referene genome
   moptions['Ref'] = margs.Ref
   if moptions['Ref']==None or (not os.path.isfile(moptions['Ref'])):
      ErrorMessage = ErrorMessage + ("\n\t reference file does not exist (%s)" % moptions['Ref'])

   # get motif-based modification
   # or specify by --fulmod/--anymod/--nomod
   moptions['motifORPos'] = margs.motifORPos
   if margs.motifORPos==1:
      moptions['motif'] = [margs.motif.upper(), margs.ModinMotif]
   elif margs.motifORPos==2:
      moptions['fulmod'] = margs.fulmod
      if moptions['fulmod']==None: # completely modificated positions
         ErrorMessage = ErrorMessage + ("\t There is no parameter for --fulmod.")
      moptions['anymod'] = margs.anymod
      if moptions['anymod'] == None: # patially modificated positions
         ErrorMessage = ErrorMessage + ("\t There is no parameter for --anymod.")
      moptions['nomod'] = margs.nomod
      if moptions['nomod'] == None: # completely unmodified posisionts
         ErrorMessage = ErrorMessage + ("\t There is no parameter for --nomod.")
   else:
      ErrorMessage = ErrorMessage + ("\tmotifORPos value (%d) is not supported." % margs.motifORPos)

   # print help document if any required options are not provided.
   printParameters(moptions)
   if not ErrorMessage=="":
      ErrorMessage = "Please provide correct parameters" + ErrorMessage
      print(ErrorMessage)
      parser.print_help();
      parser.parse_args(['getfeatures', '--help']);
      sys.exit(1)

   myGetFeatureBasedPos.getFeature_manager(moptions)
コード例 #2
0
def mGetFeatures(margs):
    from scripts import myGetFeatureBasedPos

    moptions, ErrorMessage = mCommonParam(margs)
    moptions['posneg'] = margs.posneg
    moptions['fnum'] = margs.fnum
    ErrorMessage = ErrorMessage + non_negative(moptions['fnum'], 'fnum')
    moptions['size_per_batch'] = margs.size_per_batch
    if moptions['size_per_batch'] < 0.001: moptions['size_per_batch'] = 0.001

    moptions['basecall_1d'] = margs.basecall_1d
    moptions['basecall_2strand'] = margs.basecall_2strand

    moptions['region'] = [None, None, None]
    if not (margs.region == None or margs.region.strip() == ''):
        rsp = margs.region.split(':')
        for rv_ind in range(len(rsp)):
            rsp[rv_ind] = rsp[rv_ind].strip()
            if not rsp[rv_ind] == '':
                moptions['region'][rv_ind] = rsp[rv_ind]

    moptions['Ref'] = margs.Ref
    if moptions['Ref'] == None or (not os.path.isfile(moptions['Ref'])):
        ErrorMessage = ErrorMessage + (
            "\n\t reference file does not exist (%s)" % moptions['Ref'])

    moptions['motifORPos'] = margs.motifORPos
    if margs.motifORPos == 1:
        moptions['motif'] = [margs.motif.upper(), margs.ModinMotif]
    elif margs.motifORPos == 2:
        moptions['fulmod'] = margs.fulmod
        if moptions['fulmod'] == None:
            ErrorMessage = ErrorMessage + (
                "\t There is no parameter for --fulmod.")
        moptions['anymod'] = margs.anymod
        if moptions['anymod'] == None:
            ErrorMessage = ErrorMessage + (
                "\t There is no parameter for --anymod.")
        moptions['nomod'] = margs.nomod
        if moptions['nomod'] == None:
            ErrorMessage = ErrorMessage + (
                "\t There is no parameter for --nomod.")
    else:
        ErrorMessage = ErrorMessage + (
            "\tmotifORPos value (%d) is not supported." % margs.motifORPos)

    printParameters(moptions)
    if not ErrorMessage == "":
        ErrorMessage = "Please provide correct parameters" + ErrorMessage
        print(ErrorMessage)
        parser.print_help()
        parser.parse_args(['getfeatures', '--help'])
        sys.exit(1)

    myGetFeatureBasedPos.getFeature_manager(moptions)