code: def BLASTquery(query,database,program,filter=None,\
                 format_type=None, expect=None,\
                 nucl_reward=None, nucl_penalty=None,\
                 gapcosts=None, matrix=None,\
                 hitlist_size=None, descriptions=None,\
                 alignments=None,\
                 ncbi_gi=None, threshold=None,\
                 word_size=None, composition_based_statistics=None,\
                 organism=None, others=None,\
                 num_threads=None, baseURL="http://blast.ncbi.nlm.nih.gov",\
                verbose=False):
      if organism:
          organism=organism.replace(" ", "%20").replace("(", "%28").replace(")", "%29").replace(":", "%3A")
          EQ_MENU=organism
      else:
          EQ_MENU=None
      URL=baseURL+"/Blast.cgi?"
      URL=URL+"QUERY="+str(query)+"&DATABASE="+str(database)+"&PROGRAM="+str(program)
      for o,varname in zip([filter, format_type, expect, nucl_reward, nucl_penalty,\
                gapcosts, matrix, hitlist_size, descriptions, alignments,\
                ncbi_gi, threshold, word_size, composition_based_statistics,\
                EQ_MENU, num_threads],\
                ['FILTER' , 'FORMAT_TYPE', 'EXPECT', 'NUCL_REWARD', 'NUCL_PENALTY',\
                'GAPCOSTS', 'MATRIX', 'HITLIST_SIZE', 'DESCRIPTIONS', 'ALIGNMENTS',\
                'NCBI_GI', 'THRESHOLD', 'WORD_SIZE', 'COMPOSITION_BASED_STATISTICS',\
                'EQ_MENU', 'NUM_THREADS']):
          if o:
              URL=URL+"&"+ varname +"="+str(o)
      if others:
          URL=URL+"&"+others
      URL=URL+"&CMD=Put"
      if verbose:
          print(URL)
          sys.stdout.flush()
      response=requests.get(url = URL)
      r=response.content.split("\n")
      RID=[ s for s in r if "RID = " in s ]
      if len(RID) > 0:
          RID=RID[0].split(" ")[-1]
      else:
          print("Could not return an RID for this query.")
          RID=None
      return RID